Guest_imported
New member
- Jan 1, 1970
- 0
When I delete an excel row in a for loop the row gets deleted but the row under it is then shifted up to compensate. This means that on the next loop around I'm looking at what is essentially two rows ahead originally.....
What I need is something that lets me go back one in the loop to get the shifted up row and not skip over it. Anybody think of a work around for that?
Here's the current For loops:
counter = 0
For Each r In ws.UsedRange.Rows
For Each r2 In r.Columns
' Check each cell for a value.
If r2.Cells(1, 1).Value <> "" Then
counter = 1
End If
Next r2
If counter = 0 Then
r.Rows.Delete (xlShiftUp)
End If
counter = 0
Next r
Thanks for any help and time,
Tom.
What I need is something that lets me go back one in the loop to get the shifted up row and not skip over it. Anybody think of a work around for that?
Here's the current For loops:
counter = 0
For Each r In ws.UsedRange.Rows
For Each r2 In r.Columns
' Check each cell for a value.
If r2.Cells(1, 1).Value <> "" Then
counter = 1
End If
Next r2
If counter = 0 Then
r.Rows.Delete (xlShiftUp)
End If
counter = 0
Next r
Thanks for any help and time,
Tom.