I have a loop that is trying to remove duplicate values in a collection.
As in:
For Each iitem In newArea.theCollection
For q = 2 To newArea.theCollection.Count
If iitem.X = newArea.theCollection(q).X Then
If iitem.Y = newArea.theCollection(q).Y Then
newArea.theCollection.Remove(q)
End If
End If
Next q
Next iitem
The problem is that the For loop containing q as the increment apparently does not recheck the value of newArea.theCollection.Count at each increment. So I get an out of range error after an item has been removed.
Hopefully the dilemma is clear.
Any help would be appreciated.
As in:
For Each iitem In newArea.theCollection
For q = 2 To newArea.theCollection.Count
If iitem.X = newArea.theCollection(q).X Then
If iitem.Y = newArea.theCollection(q).Y Then
newArea.theCollection.Remove(q)
End If
End If
Next q
Next iitem
The problem is that the For loop containing q as the increment apparently does not recheck the value of newArea.theCollection.Count at each increment. So I get an out of range error after an item has been removed.
Hopefully the dilemma is clear.
Any help would be appreciated.