Dear All,
I am working an Excel 2007 document with multiple worksheets. I like to add a calendar in each tab. The calendar needs to become visible in multiple cells when you select the cell.
Cells: F20 D21 F28 F29 F31 F40 F41 F42 F43 F44
I am struggling with the VBA code; I am not able to add the cells above in the code.
Who is able to help me?
Thanks,
Martin
VBA:
Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
ActiveCell.NumberFormat = "mm/dd/yyyy"
ActiveCell.Select
End Sub
Now paste this code in in the same place, you may need to change the range, I used A1:A10
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("A1:A10"), Target) Is Nothing Then
Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
Calendar1.Top = Target.Top + Target.Height
Calendar1.Visible = True
Calendar1.Value = Date
ElseIf Calendar1.Visible Then Calendar1.Visible = False
End If
End Sub
I am working an Excel 2007 document with multiple worksheets. I like to add a calendar in each tab. The calendar needs to become visible in multiple cells when you select the cell.
Cells: F20 D21 F28 F29 F31 F40 F41 F42 F43 F44
I am struggling with the VBA code; I am not able to add the cells above in the code.
Who is able to help me?
Thanks,
Martin
VBA:
Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
ActiveCell.NumberFormat = "mm/dd/yyyy"
ActiveCell.Select
End Sub
Now paste this code in in the same place, you may need to change the range, I used A1:A10
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Range("A1:A10"), Target) Is Nothing Then
Calendar1.Left = Target.Left + Target.Width - Calendar1.Width
Calendar1.Top = Target.Top + Target.Height
Calendar1.Visible = True
Calendar1.Value = Date
ElseIf Calendar1.Visible Then Calendar1.Visible = False
End If
End Sub