There are a couple of other ways
1. (I am not recommending this), is to shuffle the data down. So move
4-UBound down by 1, and the repeat on the next iteration, or even be smarter
and move 4 & 5 down 1, 7 & 8 down 2, etc.
2. Copy the array to a worksheet range, delete every third item in that
range (remembering to do it backwards), reload the array. You don't even
have to ReDim it.
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"chris" wrote in message
...
Just as a matter of Procedu You cannot intermittently remove elements
of an array to resize it.
You can either expand its upper limit or reduce it: but from top down
losing elements 600,000, 599,999...
So Franks suggestion is your only option.
Dim Array2( ), i as Single, j as Single
For i = 1 to Ubound(NumArray) '<< I don't know what your option base is
If Not NumArray(i) ="" Then
j = j +1 '<< put this here if Option base is 1, but not below!
Redim Preserve Array2(j)
Array2(j) = NumArray(i)
j = j +1 '<< put this here if Option base is 0, but not at
begining!
End If
Next
----- ExcelMonkey wrote: -----
I have a 1-D VBA array with 600,000 elements.
For X = 1 To MAX 'Max = 600,000
NumArray(X) = X
Next X
I then go into the array and randomly delete various data in the
elements. Lets say every 3rd element. I would write looping code
around something like NumArray(3) = "", NumArray(6) = "" etc...
I want to be able to redimension the array so that all the elements
with deleted data ("") are removed. So now the array size is only
400,000. How do I this?
Thank-you
---
Message posted from http://www.ExcelForum.com/