-
No, you can ignore local variables. VBA will tidy things up on its own. As stated, the only things of any realistic concern are application objects. You are not using any.
The only things you can destroy on your own are objects you give a value to with the Set instruction. In Greg's code there a few, all Range objects. As is, there is no need to explicitly destroy them with a Set = Nothing. VBA can handle things. I only really mentioned this subject as a comment on the nada performance issue regarding .Start = .End versus .Collapse.
Local variables (or even Public ones) such a Longs, or Strings are assigned a memory block when declared. For example, a Long is assigned 4 bytes. Once it is assigned, it remains (persists) until the routine that holds it terminates. So, regardless of VALUE ( 1 or 1,500 or 2,000,000), the declared Long uses 4 bytes for the Scope of the procedure. BTW, you should (if you have not done so) take a good look at what Scope means. When the procedure terminates, the block of 4 bytes is released by the VBA garbage collector. You do not have to do anything.
Obviously with our modern computers with gobs of memory 4 bytes is almost meaningless. Thus it is true that the old best practices are in some ways being made pointless. However, the principles of both understanding what is going on, and doing good housekeeping still seem valid to me. Some may argue otherwise.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules