tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,924
- Office Version
- 365
- 2019
- Platform
- Windows
To clear an object variable, you would set it to nothing.
How would you clear a non-object variable?
I ask because in the following code, the variable a is declared at the module level, so every time the sub is run, the variable's value increases.
I want the variable a to "clear" after the sub that uses it has ended.
The reason it's declared at the module level, as opposed to the procedure level, is I have other subs that use the variable a later on (not shown here).
Thanks
How would you clear a non-object variable?
I ask because in the following code, the variable a is declared at the module level, so every time the sub is run, the variable's value increases.
I want the variable a to "clear" after the sub that uses it has ended.
Code:
Option Explicit
Dim a As Integer
Sub Test()
a = a + 1
End Sub
The reason it's declared at the module level, as opposed to the procedure level, is I have other subs that use the variable a later on (not shown here).
Thanks
Last edited: