Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Global Variables
Hello,
Maybe I just don't get it but I seem to be having a bit of trouble with my global variables. Proc. level variables are simple. Module level variables are available to the module that they are declared in. Where and how do I declare a global variable? I put: Public gsFile As String in 'ThisWorkbook' module and in Auto_Open I put: gsFile = Thisworkbook.Path & DB_FILE The problem is that the variable looses its value once the sub routine ends... How do I use the variable and retain its value while the workbook is open? Ernst. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Global Variables
Ernst
Declare the variable using the Public keyword in a standard module, not the ThisWorkbook class module. It will then be available to the entire project -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England HIS "Ernst Guckel" wrote in message ... Hello, Maybe I just don't get it but I seem to be having a bit of trouble with my global variables. Proc. level variables are simple. Module level variables are available to the module that they are declared in. Where and how do I declare a global variable? I put: Public gsFile As String in 'ThisWorkbook' module and in Auto_Open I put: gsFile = Thisworkbook.Path & DB_FILE The problem is that the variable looses its value once the sub routine ends... How do I use the variable and retain its value while the workbook is open? Ernst. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Global Variables
Thanks. Seems to work...
"Nick Hodge" wrote: Ernst Declare the variable using the Public keyword in a standard module, not the ThisWorkbook class module. It will then be available to the entire project -- HTH Nick Hodge Microsoft MVP - Excel Southampton, England HIS "Ernst Guckel" wrote in message ... Hello, Maybe I just don't get it but I seem to be having a bit of trouble with my global variables. Proc. level variables are simple. Module level variables are available to the module that they are declared in. Where and how do I declare a global variable? I put: Public gsFile As String in 'ThisWorkbook' module and in Auto_Open I put: gsFile = Thisworkbook.Path & DB_FILE The problem is that the variable looses its value once the sub routine ends... How do I use the variable and retain its value while the workbook is open? Ernst. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Global vs Local variables | Excel Programming | |||
Global variables cleared by forms? | Excel Programming | |||
Global Variables using User Forms | Excel Programming | |||
Global Variables Not Accessible | Excel Programming | |||
Declaring Global Variables | Excel Programming |