Pop-up calendar

B

BumblebeeFan

We use a pop-up calendar in one of our forms for users to select a start and
end date (only one calendar for both selections). Once the user selects a
start date, is there a way to have the calendar "pop-up" in the same month as
the start date rather than the default current month?

I've learned a great deal from reading other posts! This is a great place
for new "bigger, better, faster" ideas!
 
B

BSc Chem Eng Rick

Hi BBFan

I'm not sure which Pop up calender you are using but below is a procedure
which uses the Microsoft DateTime Picker. When the start date is changed,
then the end date value tracks it. Be careful with this because if you change
the start date after you pick your end date, your end date will change.

Note the below procedure is inserted into the code for the userform NOT a
separate module. DTPicker1 is the start date and DTPicker2 is the end date.

Private Sub DTPicker1_Change()
DTPicker2.Value = DTPicker1.Value
End Sub

If this helps please click "Yes"
<><><><><><><><><><>
 
B

BumblebeeFan

Hi Rick,

Sorry... but think I'm lost. Maybe it'll help if I show you the calendar?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim Rng1 As Range

'Assign the range to work with
Set Rng1 = Range("b12,g12")

'Only work on assigned range
If Intersect(Target, Rng1) Is Nothing Then Exit Sub

'Cancel cell editing that would normally trigger when you double click
Cancel = True

'Call the userform
UserForm1.Show

End Sub

I added the DTPicker just below - think I've completely misunderstood what
to do...

BBFan
 
B

BSc Chem Eng Rick

Just to make sure I understand, the pop-up calender is a Control in
"Userform1" right? If that is the case, what control is it? You can see this
by opening up the properties window and seeing the description next to
"(Name)" when you click on the calender control.

Once you identify the name of your control, click the Userform and press
"F7" to go to the code for the Userform itself (you could also do this by
right clicking the Userform in the Project window and selecting "View Code").
Now you will see two drop-down menus at the top just under all the toolbars.
In the left hand drop-down you want to select the Pop-up calender we
identified above for your start date. You will see that some code is
automatically entered but it is more than likely the wrong event, so click
the right hand drop down and find the event "Change". This will initialise
another "Private Sub". Now all you do is put the code I gave you earlier into
that sub and there you have it.
 
B

BumblebeeFan

Thanks! I'm copying this and working on it (at work <grin>) tomorrow... will
give you an 'update' tomorrow after work. Thanks again for your time and
explanation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top