Hi all,
I'm using the following code to delete rows.
In practice the range is something like C3:C50, but my problem is that only every other row is being delete. I understand why, because the row gets delete, next row moves up so 15 becomes 14 and gets skipped assuming it is also "complete".
So I understand what's going on, but I don't know what the best way to fix it is... maybe store the ranges to be deleted and do them all at once? or is there a way of telling the For Each to go back a step? Like the opposite of Next?
Thanks
I'm using the following code to delete rows.
VBA Code:
For Each cell in sTasks.Range("C3:C" & sRange)
If cell.value = "Completed" then cell.entirerow.delete
next
In practice the range is something like C3:C50, but my problem is that only every other row is being delete. I understand why, because the row gets delete, next row moves up so 15 becomes 14 and gets skipped assuming it is also "complete".
So I understand what's going on, but I don't know what the best way to fix it is... maybe store the ranges to be deleted and do them all at once? or is there a way of telling the For Each to go back a step? Like the opposite of Next?
Thanks