ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   preserving variable from userform (https://www.excelbanter.com/excel-programming/376168-preserving-variable-userform.html)

Gary Keramidas

preserving variable from userform
 
any way to preserve a variable set when an optionbutton is true, a
commandbutton is clicked and the userform hidden? doesn't seem to want to be
available after it's hidden. i know i could store it on a sheet, but didn't want
to do that. even tried a public variable and it didn't work either

--


Gary




Gary Keramidas

preserving variable from userform
 
seems to be working now and i didn't change anything.

--


Gary


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
any way to preserve a variable set when an optionbutton is true, a
commandbutton is clicked and the userform hidden? doesn't seem to want to be
available after it's hidden. i know i could store it on a sheet, but didn't
want to do that. even tried a public variable and it didn't work either

--


Gary






Jim Cone

preserving variable from userform
 
Hi Gary,
Well this is the answer I was going to give: <g
As long as the form is not Unloaded then all you need is...
x = UserForm1.OptionButton1.Value

If it is some value you determined while the form was open,
then assign the value to the .Tag property of the OptionButton ...
OptionButton1.Tag = "Mush" or OptionButton1.Tag = CStr(LongVariable)
Then after the form is hidden...
x = CLng(UserForm1.OptionButton1.Tag)
Regards,
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Gary Keramidas"
<GKeramidasATmsn.com wrote in message
any way to preserve a variable set when an optionbutton is true, a
commandbutton is clicked and the userform hidden? doesn't seem to want to be
available after it's hidden. i know i could store it on a sheet, but didn't want
to do that. even tried a public variable and it didn't work either

--


Gary




Gary Keramidas

preserving variable from userform
 
thanks jim

--


Gary


"Jim Cone" wrote in message
...
Hi Gary,
Well this is the answer I was going to give: <g
As long as the form is not Unloaded then all you need is...
x = UserForm1.OptionButton1.Value

If it is some value you determined while the form was open,
then assign the value to the .Tag property of the OptionButton ...
OptionButton1.Tag = "Mush" or OptionButton1.Tag = CStr(LongVariable)
Then after the form is hidden...
x = CLng(UserForm1.OptionButton1.Tag)
Regards,
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Gary Keramidas"
<GKeramidasATmsn.com wrote in message
any way to preserve a variable set when an optionbutton is true, a
commandbutton is clicked and the userform hidden? doesn't seem to want to be
available after it's hidden. i know i could store it on a sheet, but didn't
want
to do that. even tried a public variable and it didn't work either

--


Gary







All times are GMT +1. The time now is 02:11 PM.

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