Variables that survive an entire session

E

eugene

Hi,

I would like to initialize a few arrays (info taken from a worksheet) at the
beginning of a session and have them survive the entire session even though
many different macros will run and end during the session. Currently, I
reload the arrays each time a macro is run. But it would be neater if I would
not have to do this. I have tried public, but the array values do not seem to
survive the end of a macro.

My public is declared in a module, and initialized when a "driver" macro
begins to run. The driver is fired each time the user right clicks on a
sheet. The driver macro calls many subs. The variables survive until the end
but do not retain their value when a sheet is right clicked a second time.
The variables have to be initialized again.

Is what I am asking possible to do?
 
B

Brian Taylor

Public variables are public to the procedures or functions within that
module. If you wanted a variable that retained its value outside the
module then you would need to declare a global variable:

Global myarray(0 to 50) as string
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top