ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can I reset an array to myarray() (https://www.excelbanter.com/excel-programming/292052-re-can-i-reset-array-myarray.html)

Alan Beban[_4_]

Can I reset an array to myarray()
 
From the On-Line Help:

Erase Statement


Reinitializes the elements of fixed-size arrays and releases
dynamic-array storage space.

Syntax

Erase arraylist

The required arraylist argument is one or more comma-delimited array
variables to be erased.

Remarks

Erase behaves differently depending on whether an array is fixed-size
(ordinary) or dynamic. Erase recovers no memory for fixed-size arrays.
Erase sets the elements of a fixed array as follows:

Type of Array Effect of Erase on Fixed-Array Elements
Fixed numeric array Sets each element to zero.
Fixed string array (variable length) Sets each element to a zero-length
string ("").
Fixed string array (fixed length) Sets each element to zero.
Fixed Variant array Sets each element to Empty.
Array of user-defined types Sets each element as if it were a separate
variable.
Array of objects Sets each element to the special value Nothing.



Erase frees the memory used by dynamic arrays. Before your program can
refer to the dynamic array again, it must redeclare the array variable's
dimensions using a ReDim statement.

Alan Beban


Dan wrote:
I want to clean out a public array that I have grown dynamically and start over as if it was the first time into the code.

ReDim myarray() gives an error message.



dan

Can I reset an array to myarray()
 
Thanks you guys are all great

I looked all through the online help but was stuck on redim - never thought of erase!


All times are GMT +1. The time now is 05:08 PM.

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