Читать книгу Excel 2019 Power Programming with VBA - Michael Alexander, Dick Kusleika - Страница 149
Scoping variables
ОглавлениеA variable's scope determines in which modules and procedures you can use the variable. Table 3.2 lists the three ways in which a variable can be scoped.
TABLE 3.2 Variable Scope
Scope | To Declare a Variable with This Scope |
Single procedure | Include a Dim or Static statement within the procedure. |
Single module | Include a Dim or Private statement before the first procedure in a module. |
All modules | Include a Public statement before the first procedure in a module. |
We discuss each scope further in the following sections.