Calendar UserForm question

DougRobertson

Active Member
Joined
Sep 22, 2009
Messages
334
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have created a pop-up calendar userform in Excel VBA (2010). It works well for clicking on a day in the calendar and having the macro enter that date in a specific cell. However, I don't want to do that.

I'd prefer having the date information kept in the memory, so I can use it in different ways for file naming etc., but when the macro switches back to the original macro, iDate (for instance) goes back to Empty.

Is there a way to have the date info stay in memory?

Thanks in advance,

~ Doug
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Put the declaration for iDate in a module making it public.

iDate will keep the last picked date until the app closes.

Code:
Public iDate As Date
Sub test()
    MsgBox iDate
End Sub
Code in the form:

Code:
Private Sub DTPicker1_Change()
    iDate = Me.DTPicker1.Value
End Sub
 
Upvote 0
Could you be a little more specific - the macro doesn't seem to like the code.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,286
Members
449,076
Latest member
kenyanscott

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top