Calendar UserForm question

DougRobertson

Active Member
Joined
Sep 22, 2009
Messages
320
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
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

tlowry

Well-known Member
Joined
Nov 3, 2011
Messages
1,367
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
 

DougRobertson

Active Member
Joined
Sep 22, 2009
Messages
320
Office Version
  1. 365
Platform
  1. Windows
Could you be a little more specific - the macro doesn't seem to like the code.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,402
Messages
5,601,475
Members
414,452
Latest member
Dannysamworth

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
Top