#1   Report Post  
Posted to microsoft.public.excel.misc
BillCPA
 
Posts: n/a
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
Chip Pearson
 
Posts: n/a
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
date format problem Nigel Excel Discussion (Misc queries) 7 May 11th 05 12:57 PM
Account for Public Holidays POM Excel Discussion (Misc queries) 0 March 2nd 05 11:47 AM
How do I link to an Outlook public folder from an Excel spreadshe. DJBaker Excel Discussion (Misc queries) 0 January 28th 05 07:35 PM
Problem accessing Oracle Public Synonyms from Microsoft Excel 2002 Sandeep Excel Discussion (Misc queries) 1 January 5th 05 09:31 AM
Public Function Monty Excel Discussion (Misc queries) 9 December 24th 04 06:35 PM


All times are GMT +1. The time now is 04:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"