Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Passing variable to and from a form

If I declare a variable as Public in a normal module, then update the
variable in a form module - the update is lost as soon as I exit the form.

Any way around it?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Passing variable to and from a form

Dan,
It will not
- if you are not using "End" anywhere,
- or resetting your project, by using the <stop icon in the VBE.
- And in a standard module, you have
Dim YourVar As <SomeDataType

Also, are you using Option Explicit in all modules ?

<Standard Module code
Public MyVar As String
<Standard Module code

<UserForm code
Private Sub UserForm_Click()
MyVar = MyVar & "Updated from userform" & vbNewLine
End Sub
<UserForm code

<Worksheet code
Private Sub CommandButton1_Click()
MsgBox MyVar
UserForm1.Show 'Note showing modal
MsgBox MyVar
'End
End Sub
<Worksheet code

Test a few times, then uncomment the "End" and test a few more times.

NickHK

"Dan" wrote in message
...
If I declare a variable as Public in a normal module, then update the
variable in a form module - the update is lost as soon as I exit the form.

Any way around it?

Thanks



Reply
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 a variable from sheet to form to another sheet anny Excel Programming 2 May 7th 06 11:45 PM
Passing variable to VarType of other Variable ExcelMonkey[_190_] Excel Programming 3 February 22nd 05 01:38 PM
passing variable to file... Ernst Guckel[_2_] Excel Programming 1 June 2nd 04 05:46 PM
passing control value from one form to another form mark kubicki Excel Programming 1 April 3rd 04 01:27 AM
Passing variable from one sub to another Medemper Excel Programming 0 February 26th 04 10:23 PM


All times are GMT +1. The time now is 09:03 AM.

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

About Us

"It's about Microsoft Excel"