LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variable values to userform control KJ-clueless Excel Discussion (Misc queries) 2 November 27th 07 10:51 PM
Passing Variable to LINEST RW Excel Worksheet Functions 5 May 24th 05 07:00 PM
passing variable to file... Ernst Guckel[_2_] Excel Programming 1 June 2nd 04 05:46 PM
Passing variable from one sub to another Medemper Excel Programming 0 February 26th 04 10:23 PM
Passing a value to a variable from Userform Neal Steiner Excel Programming 1 July 18th 03 09:12 PM


All times are GMT +1. The time now is 12:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"