Guangwen has attended:
Excel Advanced course
Excel VBA Intro Intermediate course
Excel VBA
How many different ways can variables be defined?
Variable Scope
Hi Guangwen
When declaring variables it must be remembered that there are 3 levels. They are:
Procedure-Level Variables
This is the most widely used variables. They are declared inside the Procedure itself (using the Dim keyword). Only the procedure that contains the variable declaration can use it. As soon as the Procedure finishes, the variable is destroyed.
Module-Level Variables
These are variables that are declared outside the Procedure itself in the Declarations section of a module (using the Dim keyword).
All variables declared at this level are available to all Procedures within the Module.
Public Variables
These variables are declared at the top of any standard Public module. Public variables are available to all procedures in all modules in a project
The Public keyword can only be used in the Declarations section
Hope this helps
Carlos