View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default How to maintain size of array: UniqRow

A couple of issues jump out at me here.

In your For...Each...Next loop:
You recreate a new collection named "UniqRow".

A collection is not an array.

You read each cell of the worksheet. This is rather slow.

Suggestion:
Dump the entire sheet into an array and work the array to remove
duplicate rows.

Example:
Dim vData As Variant, vaNums()
Dim i As Long, k As Long
vData = ActiveSheet.UsedRange
For i = LBound(vData) To UBound(vData)
If vData(i, 3) = "X" Then
ReDim Preserve vaNums(k)
vaNums(k) = vData(i, 1): k = k + 1
End If
Next 'i

Now, vaNums is na array that contains a list of the numbers in ColA
where ColC contained "X".

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc