ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Varible scope (https://www.excelbanter.com/excel-programming/410041-varible-scope.html)

miek

Varible scope
 
Is it possible to declare a varible that can be seen (availble) from any
Sub(routine) within the current Module1?

If so How

Chip Pearson

Varible scope
 
Declare the variable outside of and before any procedure declaration. Use
"Public" instead of "Dim" if you want to variable to be visible from any
module (not just the module in which it is declared) or use "Private"
instead of "Dim" if you want the variable to be visible only from within the
module in which it is declared.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"miek" wrote in message
...
Is it possible to declare a varible that can be seen (availble) from any
Sub(routine) within the current Module1?

If so How



Dave Peterson

Varible scope
 
At the top of the module:
Dim myVar as Variant 'or whatever.

Use:
Public myVar as Variant
If you want it seen in all modules.

miek wrote:

Is it possible to declare a varible that can be seen (availble) from any
Sub(routine) within the current Module1?

If so How


--

Dave Peterson


All times are GMT +1. The time now is 10:38 PM.

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