jamesperrin1976
New Member
- Joined
- Feb 8, 2009
- Messages
- 13
Please can someone help me?
I have found some code on the internet to open the calendar control when the operator clicks on an unlocked cell in my spreadsheet (see the code below).
My problem is that I want the calendar to close if the operator hits the ESC key or (if possible) starts writing in the cell instead of selecting a date from the calendar. Does anyone know how to do this? I have seen a method using a userform but I want the calendar to appear without a titlebar.
Thanks in advance,
James
I have found some code on the internet to open the calendar control when the operator clicks on an unlocked cell in my spreadsheet (see the code below).
My problem is that I want the calendar to close if the operator hits the ESC key or (if possible) starts writing in the cell instead of selecting a date from the calendar. Does anyone know how to do this? I have seen a method using a userform but I want the calendar to appear without a titlebar.
Thanks in advance,
James
Code:
Private Sub Calendar1_Click()
ActiveCell.Value = CDbl(Calendar1.Value)
ActiveCell.NumberFormat = "dd-mmm-yy"
ActiveCell.Select
Calendar1.Visible = False
End Sub
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Locked = False Then
With Calendar1
.Visible = True
.Left = Target.Left
.Top = Target.Top + Target.Height
End With
If IsDate(ActiveCell.Value) Then
Calendar1.Value = ActiveCell.Value
Else
Calendar1.Value = Date
End If
Else
Calendar1.Visible = False
End If
End Sub