I am trying to remove duplicate elements from an excel array. I imagine I’m not doing this in the most efficient way, and it doesn’t seem to be working anyways:
For lrw = 1 To UBound(rcArray)
For copyIndex = lrw + 1 To .Rows.Count
If rcArray(copyIndex) = rcArray(lrw) Then
rcArray(lrw).Delete
End If
Next copyIndex
Next lrw
Do I need to reDim the array? Does anyone have a link to some code for this?
Thanks in advance!
While it would take me a while to cobble up some code the best bet would be to create a new array and copy the values you want to keep to it. You can’t just delete elements in the middle of an array.
Redim only allows you to add or remove elements from the end of the array.