ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   variable available after userform (https://www.excelbanter.com/excel-programming/407863-variable-available-after-userform.html)

filo666

variable available after userform
 
Hi all; I have this macro


public var1,var2, var3 as integer
sub getdata()
var1=cells(3,1)
load userform1
userform1.show ' In userform1 the var1 should be used and then the value of
cells(3,1) changed, var2 is obtained from userform1.
if var2<1 then
load userform2
userform2.show
else

load userform3
userform3.show
end if
'var3 is obtained from userform2 or 3 and used
end sub

my problem is with the variables, when I open the userform1 var1 loose its
value, also, when I get values from userform2 and 3 I'm not able to operate
with them in my macro, could someone give me a small explanation about
variables in userforms and how to solve my problem???

TIA


Bob Phillips

variable available after userform
 
If you have defined var1 etc as public variables in a STANDARD code module
you should be okay, they should persist.

Do you have further variables called var1 etc. in the actual form modules?

Post some of that code that isn't working.

BTW, no need to load and show, show does a load if not already in memory.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"filo666" wrote in message
...
Hi all; I have this macro


public var1,var2, var3 as integer
sub getdata()
var1=cells(3,1)
load userform1
userform1.show ' In userform1 the var1 should be used and then the value
of
cells(3,1) changed, var2 is obtained from userform1.
if var2<1 then
load userform2
userform2.show
else

load userform3
userform3.show
end if
'var3 is obtained from userform2 or 3 and used
end sub

my problem is with the variables, when I open the userform1 var1 loose its
value, also, when I get values from userform2 and 3 I'm not able to
operate
with them in my macro, could someone give me a small explanation about
variables in userforms and how to solve my problem???

TIA




Peter T

variable available after userform
 
In another thread I noticed you, I mean filo666 not Bob!, posted your
userform code in which you appeared to close the form using the End
statement. I strongly advised against using the End statement but if you are
still using it all your public variables will be destroyed.

Regards,
Peter T

"Bob Phillips" wrote in message
...
If you have defined var1 etc as public variables in a STANDARD code module
you should be okay, they should persist.

Do you have further variables called var1 etc. in the actual form modules?

Post some of that code that isn't working.

BTW, no need to load and show, show does a load if not already in memory.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my

addy)



"filo666" wrote in message
...
Hi all; I have this macro


public var1,var2, var3 as integer
sub getdata()
var1=cells(3,1)
load userform1
userform1.show ' In userform1 the var1 should be used and then the value
of
cells(3,1) changed, var2 is obtained from userform1.
if var2<1 then
load userform2
userform2.show
else

load userform3
userform3.show
end if
'var3 is obtained from userform2 or 3 and used
end sub

my problem is with the variables, when I open the userform1 var1 loose

its
value, also, when I get values from userform2 and 3 I'm not able to
operate
with them in my macro, could someone give me a small explanation about
variables in userforms and how to solve my problem???

TIA







All times are GMT +1. The time now is 12:18 AM.

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