ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   free up memory by deleting variables (https://www.excelbanter.com/excel-programming/284805-free-up-memory-deleting-variables.html)

clui[_11_]

free up memory by deleting variables
 

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

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~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

pk

free up memory by deleting variables
 
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!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~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
.


Tom Ogilvy

free up memory by deleting variables
 
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" wrote in 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!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~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



Tom Ogilvy

free up memory by deleting variables
 
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 wrote in message
...
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!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~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
.




Alex J

free up memory by deleting variables
 
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" wrote in message
...
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 wrote in message
...
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!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~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
.







All times are GMT +1. The time now is 07:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com