Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear contents of array

Status
Not open for further replies.

osx99

Technical User
Apr 9, 2003
250
GB
What is the best way to clear the contents of an array in VBA?

eg i have a constant 376 variables for upto 1 - 100 items spread across a number of days. the no. of items vary each day.

Say the code runs with 50 items for the first day then Datastor(49,376) is full of data, the following day if only 25 items are present then the remaining array after Datastor(25,376) contains data I don't need from the previous loop

Is there a quick way of clearing out the contents of the array stated below without a full cycle through setting everything to null?

Dim DataStor(100, 376) As Variant
 
erase Datastor

_________________
Bob Rashkin
 
osx99,
If it helps you can clear and change the dimensions in the same step.

[tt]ReDim DataStor(100, 376) As Variant[/tt]

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Only if Datastor was DIMmed as a dynamic array. You cannot redim a static array.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top