If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I tried to clean up an array, using the following code. The redim preserve statement doesn't work.
Can someone help out?
Code:
Public Sub CleanArray()
Dim x, y As Variant
Dim i, c As Integer
'Dump all values in a range to an array
y = Sheets("Sheet1").Range("A1:A175")
x = y
Erase x 'reset the new array elements
'Weed out the blanks in the array
i = 1 'counter for old array
c = 0 'counter for new array
While i < 175
If Not IsEmpty(y(i, 1)) Then
c = c + 1
ReDim Preserve x(c, 1) 'This one doesn't work
x(c, 1) = y(i, 1)
End If
i = i + 1
Wend
End Sub