Hello,
In my project the user inputs text to an input box. When a separate subroutine tries to access the variable it has become empty. Essentially my question is how do you use the same variable in several different subroutines?
Please help, John
Hello,
In my project the user inputs text to an input box. When a separate subroutine tries to access the variable it has become empty. Essentially my question is how do you use the same variable in several different subroutines?
Please help, John
Hey John, Welcome to VBAX
Take a look at OZGrid's article on Variable Scope:
http://www.ozgrid.com/VBA/variable-scope-lifetime.htm
It uses Excel as its example, but the concept still holds for all VBA variables (that I know of )
Good luck!
New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.
In one of your VBA modules, declare a public variable. Then, when you use the inputbox, assign the value to the public variable. It will always be available and can be changed when the input box is used again or when the vba code changes it.
ttfn
Kicker