![]() |
Public Curiosity
Just curious about using 'Public' to define variables. Is there a 'more
correct' place to list variables that you want used by all modules in a project? Module 1? Form Code module (if you are using a menu)? Completely separate module? Also curious about how VBA works here. Does it read through all modules when you open a project and pull the 'Public' variables? Or do you have to use code in a particular module before it picks up any variables listed in that module? -- Bill @ UAMS |
Public Curiosity
Public variables are typically placed in a standard code module.
It doesn't matter which code module. If you have only one module, put them there. In a large project, you might want to devote a module exclusively to public variable. This would be done only for organizations -- it would have no impact on execution of code. Don't put Public variables in the ThisWorkbook module, a userform's code module or a worksheet's code module unless you have good reason to do so and you know what you're doing. VBA will recognize all public variables at the same time. You don't have to run code in a module for that module's public variables to be 'recognized'. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "BillCPA" <Bill @ UAMS wrote in message ... Just curious about using 'Public' to define variables. Is there a 'more correct' place to list variables that you want used by all modules in a project? Module 1? Form Code module (if you are using a menu)? Completely separate module? Also curious about how VBA works here. Does it read through all modules when you open a project and pull the 'Public' variables? Or do you have to use code in a particular module before it picks up any variables listed in that module? -- Bill @ UAMS |
All times are GMT +1. The time now is 01:54 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com