ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variables that survive an entire session (https://www.excelbanter.com/excel-programming/361347-variables-survive-entire-session.html)

eugene

Variables that survive an entire session
 
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?

--
eugene

Brian Taylor

Variables that survive an entire session
 
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


eugene

Variables that survive an entire session
 
thanks
--
eugene


"Brian Taylor" wrote:

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



Rick Hansen

Variables that survive an entire session
 
Hey Brian, Public variable is a Global variable
Look in Excel Help!!!




"Brian Taylor" wrote in message
oups.com...
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




Brian Taylor

Variables that survive an entire session
 
Thanks Rick.



All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com