Читать книгу Excel 2019 Power Programming with VBA - Michael Alexander, Dick Kusleika - Страница 151
Local variables
ОглавлениеA local variable is one declared within a procedure. You can use local variables only in the procedure in which they're declared. When the procedure ends, the variable no longer exists, and Excel frees up the memory that the variable used. If you need the variable to retain its value when the procedure ends, declare it as a Static
variable. (See the section “Static variables” later in this chapter.)
The most common way to declare a local variable is to place a Dim
statement between a Sub
statement and an End Sub
statement. Dim
statements usually are placed right after the Sub
statement, before the procedure's code.