T
TxRaistlin
I am looking for a bit of clarification on the proper use of module level
variables.
Lets say a variable named myfirstrange is defined as a range at the
beginning of a module before any subroutines.
Now let's say that the first subroutine is called (from a different module)
and stores the following to this variable:
myfirstrange=worksheets("sheet1").range("a:a")
Next, a second subroutine is called (within the same module as the
variables, but again from a different calling module), is the value of
myfirstrange able to be used in the second subroutine as it was defined in
the first?
i.e. in the second subroutine, the only use of myfirstrange is as follows:
findrow=application.worksheetfunction.match("lookup value",myfirstrange,0)
Will the second subroutine recognize the actual value of the variable.
Additionally, is there any reason not to do it this way, i.e. it reduces
performance of the code, etc. And finally, is it ok to call the two
subroutines from a separate module?
The reason I am asking this question is that I would like to avoid having to
"send" a variable to a second subroutine by defining it at the module level,
as I would be sending about 100 variables, and this gets confusing at times.
Would appreciate any insight.
Thanks,
Jason Falls
variables.
Lets say a variable named myfirstrange is defined as a range at the
beginning of a module before any subroutines.
Now let's say that the first subroutine is called (from a different module)
and stores the following to this variable:
myfirstrange=worksheets("sheet1").range("a:a")
Next, a second subroutine is called (within the same module as the
variables, but again from a different calling module), is the value of
myfirstrange able to be used in the second subroutine as it was defined in
the first?
i.e. in the second subroutine, the only use of myfirstrange is as follows:
findrow=application.worksheetfunction.match("lookup value",myfirstrange,0)
Will the second subroutine recognize the actual value of the variable.
Additionally, is there any reason not to do it this way, i.e. it reduces
performance of the code, etc. And finally, is it ok to call the two
subroutines from a separate module?
The reason I am asking this question is that I would like to avoid having to
"send" a variable to a second subroutine by defining it at the module level,
as I would be sending about 100 variables, and this gets confusing at times.
Would appreciate any insight.
Thanks,
Jason Falls