ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Public Variable in ThisWorkbook (https://www.excelbanter.com/excel-programming/327231-public-variable-thisworkbook.html)

DRKML

Public Variable in ThisWorkbook
 
I want to declare some public variables as soon as I open the workbook. Can
I do that in "ThisWorkbook" or do I need to put it in a module and have
"ThisWorkbook" Open event call a routine to set the public variables?



Chip Pearson

Public Variable in ThisWorkbook
 
If the variables are going to be used in procedures outside the
ThisWorkbook module, you should declare them in the declarations
section of a regular code module, and initialize them in the Open
event procedure.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"DRKML" wrote in message
...
I want to declare some public variables as soon as I open the
workbook. Can
I do that in "ThisWorkbook" or do I need to put it in a module
and have
"ThisWorkbook" Open event call a routine to set the public
variables?





DRKML

Public Variable in ThisWorkbook
 
Thank you.

"Chip Pearson" wrote in message
...
If the variables are going to be used in procedures outside the
ThisWorkbook module, you should declare them in the declarations
section of a regular code module, and initialize them in the Open
event procedure.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"DRKML" wrote in message
...
I want to declare some public variables as soon as I open the
workbook. Can
I do that in "ThisWorkbook" or do I need to put it in a module
and have
"ThisWorkbook" Open event call a routine to set the public
variables?








All times are GMT +1. The time now is 08:56 AM.

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