PDA

View Full Version : VBA userform calendar



cmm0812
03-24-2008, 12:19 PM
I have added a calendar userform to my document and want to have it automatically appear when any cell in row "Q" is selected, rather than having the user key the shortcut. Any suggestions as to how this can be done?

Thanks

Bob Phillips
03-24-2008, 12:30 PM
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Me.Range("Q:Q")) Is Nothing Then
frm.Calendar.Show
End If
End Sub


This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.

cmm0812
03-24-2008, 12:38 PM
Thanks...

I inserted it into the sheet module, tried it out, and a "Run-time 424" error followed, stating "object required." I was then prompted to de-bug at the frm.Calendar.Show bit.

Have I done something incorrectly?

Bob Phillips
03-24-2008, 12:56 PM
My error, it should not have been frm.Calendar.Show, but form.Show, where form is the name of your calendar form.

cmm0812
03-24-2008, 02:21 PM
Thanks, it works perfectly!