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

Hi Keri

Yes, declare the variable after Option Explicit and before the first of
your Subs.
The gl doesn't make it global it is just a convention used by many to
show that this is a global variable utilised by many routines.

In your case, Answer is the number of pages, and if the question hasn't
been asked, then the value will be 0 from the original dim statement so
I don't think you need to worry about setting a Boolean as to whether
you have answered.
Just change your loops to

If answer 0 Then
For p =1 to answer
. rest of your code here