I'm using a macro to delete all rows where the value in column K is 1 or blank, but leave if it's 0.
Sub deleteRow()
Range("k2").Select
Dim Rw_count As Integer
Dim K As Integer
Rw_count = ActiveSheet.UsedRange.Rows.Count
For K = 1 To Rw_count
If ActiveCell > 0 Then
Selection.EntireRow.Delete
ElseIf ActiveCell = "" Then
Selection.EntireRow.Delete
Else
Selection.Offset(1, 0).Select
End If
Next K
End Sub
On the first run it will delete the rows where cell value is 1 but leaves all rows where cell value is blank. On the second run it takes care of blank ones too.
Note, even if there are no 1 values the macro still needs to run twice to get the job done. Messy solution is obviously to just write it twice, but i'd like to know whats going on.
Any thoughts?
Cheers
TLDR

Originally Posted by
JosephP
I see the confusion-the rows
are being deleted but the used range is not reset. add
as the last line of code
Bookmarks