Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variables
I am wanting to use a boolean variable, say Var1 named
from a User Form within a macro and then call up that variable in a subsequent Sub routine that forms part of the macro but when the sub routine is running Var1 is now empty. What am I doing wrong? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variables
You need to define the variable as global. Write in the beginning of th
module you define it as Dim Var1 - Manges -- Message posted from http://www.ExcelForum.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variables
if i understand you, you are runing 2 subs. when one sub
finishes, it dumps all of the variables. you will have to redeclair var1 in the second sub. -----Original Message----- I am wanting to use a boolean variable, say Var1 named from a User Form within a macro and then call up that variable in a subsequent Sub routine that forms part of the macro but when the sub routine is running Var1 is now empty. What am I doing wrong? . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variables
Apart from globals, my preference is to pass variables to the macros that
need them, like this: Sub tester() Dim B As Boolean B = True Call NextOne(B) B = Not B Call ThirdOne(B, "Simon says:") End Sub Sub NextOne(B As Boolean) MsgBox "Next one says " & B End Sub Sub ThirdOne(B As Boolean, S As String) MsgBox S & vbNewLine & B End Sub HTH. Best wishes Harald "mikeymay" skrev i melding ... I am wanting to use a boolean variable, say Var1 named from a User Form within a macro and then call up that variable in a subsequent Sub routine that forms part of the macro but when the sub routine is running Var1 is now empty. What am I doing wrong? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variables
i'm not sure what you mean...
but might be this.. have you checked the scope of your vairable... if its global or not? "mikeymay" wrote in message ... I am wanting to use a boolean variable, say Var1 named from a User Form within a macro and then call up that variable in a subsequent Sub routine that forms part of the macro but when the sub routine is running Var1 is now empty. What am I doing wrong? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Not at all clear on use of variables and/or object variables | Excel Discussion (Misc queries) | |||
More than 1 Variables | Excel Discussion (Misc queries) | |||
Variables in VBA | Excel Discussion (Misc queries) | |||
Variables | Excel Programming | |||
variables | Excel Programming |