![]() |
Passing variable values from userforms
Is it possible to pass a value from a variable that is in
a userform? I have a date that a user inputs in a textbox. This date is stored in a variable. Then when the user clicks the OK button on the userform, a module is called. I need that variable fromt he userform to be accessable from the module. I know its possible to pass variable values between code modules by using the public statement, but for some reason I cant get it to work from a userform to code module. Is this possible? Thanks Todd Huttenstine |
Passing variable values from userforms
In the userform code module:
Public MyVar Private Sub CommandButton1_Click() MyVar = Rnd() MyMacro End Sub ' note that the Userform is not unloaded or the value in MyVar will be lost. in a general module: Sub MyMacro() MsgBox UserForm1.MyVar End Sub But you could also just use msgbox Userform1.Textbox1.Value -- Regards, Tom Ogilvy "Todd Huttenstine" wrote in message ... Is it possible to pass a value from a variable that is in a userform? I have a date that a user inputs in a textbox. This date is stored in a variable. Then when the user clicks the OK button on the userform, a module is called. I need that variable fromt he userform to be accessable from the module. I know its possible to pass variable values between code modules by using the public statement, but for some reason I cant get it to work from a userform to code module. Is this possible? Thanks Todd Huttenstine |
All times are GMT +1. The time now is 05:10 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com