In VBA for Excel:
For i = 0 To UBound(artMaster)
For j = i To UBound(artMaster)
If i <> j And artMaster(i).VDN = artMaster(j).VDN Then
Call DeleteArrayItem(artMaster, j)
End If
Next j
Next i
How can I decrease the iterations of the loop after I have deleted one of the array items?
You can subtract 1 from your iterator. But that can be problematic and makes the code harder to understand.
Perhaps a better approach is to loop from the last item to the first (step -1). This way, your iterator remains valid as you delete items.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With