Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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





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
userform textbox to variable Peter[_61_] Excel Programming 2 July 18th 07 11:50 AM
Userform and variable Jeff Excel Discussion (Misc queries) 1 March 16th 07 03:14 PM
userform and variable Gary Keramidas Excel Programming 11 December 6th 06 05:34 PM
Variable from Userform to Macro Vikesh Jain Excel Programming 2 June 28th 06 06:13 AM
VBA Variable as userform [email protected] Excel Programming 3 April 13th 06 08:32 PM


All times are GMT +1. The time now is 08:34 PM.

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"