free up memory by deleting variables

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
 
P

pk

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!


------------------------------------------------
[/url]
~~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
 
T

Tom Ogilvy

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!
creating financial statements
 
T

Tom Ogilvy

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.

--
Regards,
Tom Ogilvy

pk said:
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!


------------------------------------------------
[/url]
~~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
 
A

Alex J

Tom,
Any guidance on using Erase (like Set Object = Nothing)? I had assumed a
program will release the memory when it completes.

Alex J

Tom Ogilvy said:
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.

--
Regards,
Tom Ogilvy

pk said:
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!


------------------------------------------------
[/url]
~~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
 
Top