On 2002-05-06 17:18, Fonged wrote:
Thanks for the post dwhj, I am trying to do it as well.
Could you make it a bit more dynamic - I need the calendar to come up and enter the date when any cell of a specific column is double clicked.
Thanks for the help.
Actually there was an error in the original code.
The BeforeDoubleClick procedure should have been :-
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$A$1" Then
UserForm1.Show
Application.EnableEvents = False
Target.Offset(1, 0).Select
Application.EnableEvents = True
End If
End Sub
If you want the calendar to appear, for example, when any cell in Column 2 (i.e. column B) is double-clicked :-
Private Sub CommandButton1_Click()
ActiveCell = Calendar1.Value
Me.Hide
End Sub
Private Sub SpinButton1_Change()
'MsgBox SpinButton1.Value
If Calendar1.Month = 12 And SpinButton1.Value > 0 Then
Calendar1.Year = Calendar1.Year + 1
Calendar1.Month = 1
ElseIf Calendar1.Month = 1 And SpinButton1.Value< 0 Then
Calendar1.Year = Calendar1.Year - 1
Calendar1.Month = 12
Else
Calendar1.Month = Calendar1.Month + SpinButton1.Value
End If
SpinButton1.Value = 0
End Sub
Private Sub SpinButton2_Change()
Calendar1.Year = Calendar1.Year + SpinButton2.Value
SpinButton2.Value = 0
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 2 Then
UserForm1.Show
Target.Offset(1, 0).Select
End If
End Sub
In the BeforeDoubleClick procedure, just change the column number to fit your needs.
This message was edited by dwhj on 2002-05-06 18:36