RE: Deleting blank values from an array



It seems that the easiest approach would be to prevent blank values from
getting added to the array in the first place. Failing that, one simple
solution is to transfer non-blank values from the original array to a second
dynamic array. Then use the second array and forget the first. I'm sure
someone has a more elegant solution. I think it would be more efficient to
sort afterwards.

'Where Arr is array containing blanks and Arr2 is dynamic array
ii = 0
For i = LBound(Arr) To UBound(Arr)
If Arr(i) <> "" Then
ReDim Preserve Arr2(ii)
Arr2(ii) = Arr(i)
ii = ii + 1
End If
Next


Regards,
Greg

"Rich J" wrote:

> I have an array that gets populated with dates from various ranges in my
> spread***. In the process blank values also get included. Once filled, I
> would like to sort the array with the earliest date in H(0) and the blank
> ones deleted by redimensioning the array.
> I figured out one way to sort but the blank ones are all in the lower
> indexes with the sorted dates at the end.
> Is there an easy way to delete the empty elements of the array either while
> sorting or another routine after the sort ?
> I used the sorting routines in this help site
>
> http://support.microsoft.com/?kbid=213818
> I tried a filter routine but it created an error
> Thanks
.