Harry Flashman
Active Member
- Joined
- May 1, 2011
- Messages
- 361
Excel VBA Variables. Using Variables in Excel VBA Macro Code
The above webpage offers the following advice about object variables:
Set rMyCell = Range("A1")
"So when we have finished using the Object Variable "rMyCell" it is a good idea to Set it back to it's default value of Nothing. eg: [...] This will mean Excel will not be reserving unnecessary memory."
Set rMyCell = Nothing
Could some please explain the issue here. Is the writer simply referring to memory used while the macro is running or is he also referring to Excel reserving memory even after the macro has finished running?
I occasionally see people set Object variable to nothing at the end of the code - but since the macro is finished what is the point of this?
Cheers
The above webpage offers the following advice about object variables:
Set rMyCell = Range("A1")
"So when we have finished using the Object Variable "rMyCell" it is a good idea to Set it back to it's default value of Nothing. eg: [...] This will mean Excel will not be reserving unnecessary memory."
Set rMyCell = Nothing
Could some please explain the issue here. Is the writer simply referring to memory used while the macro is running or is he also referring to Excel reserving memory even after the macro has finished running?
I occasionally see people set Object variable to nothing at the end of the code - but since the macro is finished what is the point of this?
Cheers