free up memory by deleting variables

  • Thread starter Thread starter clui
  • Start date Start date
C

clui

I have tons of variables in my VBA code and need to delete some of the
when they're no longer needed. What's the code for that? Fo
example, how do I delete myarray(13,18)? Thanks
 
To clear an array use: ERASE

Erase myarray(13, 18)

HTH
-----Original Message-----

I have tons of variables in my VBA code and need to delete some of them
when they're no longer needed. What's the code for that? For
example, how do I delete myarray(13,18)? Thanks!


------------------------------------------------

~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step
guide to creating financial statements
 
If it is dynamic, then

erase myarray

if it is a variant variable containing an array

myArray = ""

Otherwise I believe you would have to go out of scope.

--
Regards,
Tom Ogilvy

clui said:
I have tons of variables in my VBA code and need to delete some of them
when they're no longer needed. What's the code for that? For
example, how do I delete myarray(13,18)? Thanks!


------------------------------------------------



~~Now Available: Financial Statements.xls, a step by step guide to
creating financial statements
 
Just to add,
That doesn't free up any memory if the array is not dynamic.

from help for Erase:

Reinitializes the elements of fixed-size arrays and releases dynamic-array
storage space.
 
Tom,
Any guidance on using Erase (like Set Object = Nothing)? I had assumed a
program will release the memory when it completes.

Alex J
 
Back
Top