+ Reply to Thread
Results 1 to 2 of 2

Public Curiosity

  1. #1
    BillCPA
    Guest

    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. #2
    Chip Pearson
    Guest

    Re: 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
    news:E78544B4-C989-4217-B814-6149A9C0166F@microsoft.com...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1