View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Kent Kent is offline
external usenet poster
 
Posts: 4
Default Using a variable in more than one sub procedure

If the sub is on the same module/sheet/userform then you should just
make a global variable for it: e.g. "Dim glDescriberAnwer as long" at
the top of the form.

When the other sub(s) wants to use it, just be sure the code is smart
enough to know the un-initialized variable (i.e. 0) isn't what the user
inputted. If necessary, use a separate (boolean) global variable to
tell if the variable has been initialized or not.



keri wrote:
I currently have this is a sub and parts of the sub use the answer.
This sub will run first.

Dim answer as integer
answer = inputbox(How many sheets?)

However i would like to use the answer again in another sub that runs
later, without the input box again. Is this possible?