ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using the popup calendar (https://www.excelbanter.com/excel-programming/309643-using-popup-calendar.html)

Erik

Using the popup calendar
 
I have created a popup calendar in a user form, but I can't figure out how to
get the date clicked on into a variable in a sub. Basically, I want my sub
to call the calendar and assign the selected value to variable nDate to used
later. Any suggestions?
Erik

Tom Ogilvy

Using the popup calendar
 
Private sub Calendar1_click()
ndate = userform1.calendar1.value
End Sub

"popup calendar" is not self defining, so that is a guess.

--
Regards,
Tom Ogilvy

"Erik" wrote in message
...
I have created a popup calendar in a user form, but I can't figure out how

to
get the date clicked on into a variable in a sub. Basically, I want my

sub
to call the calendar and assign the selected value to variable nDate to

used
later. Any suggestions?
Erik




Erik

Using the popup calendar
 
Right. But how do I reference ndate in a sub in module 1?

"Tom Ogilvy" wrote:

Private sub Calendar1_click()
ndate = userform1.calendar1.value
End Sub


Tom Ogilvy

Using the popup calendar
 
at the top of the module (module10) outside any procedures (subs or
functions)

Public nDate as Date

Sub Testit()
msgbox nDate
End Sub

--
Regards,
Tom Ogilvy

"Erik" wrote in message
...
Right. But how do I reference ndate in a sub in module 1?

"Tom Ogilvy" wrote:

Private sub Calendar1_click()
ndate = userform1.calendar1.value
End Sub




Erik

Using the popup calendar
 
Thank you. I got that part of my code working.

"Tom Ogilvy" wrote:

at the top of the module (module10) outside any procedures (subs or
functions)

Public nDate as Date

Sub Testit()
msgbox nDate
End Sub

--
Regards,
Tom Ogilvy

"Erik" wrote in message
...
Right. But how do I reference ndate in a sub in module 1?

"Tom Ogilvy" wrote:

Private sub Calendar1_click()
ndate = userform1.calendar1.value
End Sub





Lucas Swanson

Using the popup calendar
 
The best way to do this is to create a global variable called nDate (or
whatever) in module1. You could also temporarily store the value in a
worksheet form on the calendar click event, & then retrieve it in your sub
procedure.

"Erik" wrote:

I have created a popup calendar in a user form, but I can't figure out how to
get the date clicked on into a variable in a sub. Basically, I want my sub
to call the calendar and assign the selected value to variable nDate to used
later. Any suggestions?
Erik



All times are GMT +1. The time now is 06:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com