I have a sheet called "Summary"
I have tried to write code to delete the rows from Row 25 onwards up to the last row in Col A, where Col B contains a zero or blank
The macro takes a few mins to run and there is a maximum of 1000 rows
It would be appreciated if someone could kindly amend my code
I have tried to write code to delete the rows from Row 25 onwards up to the last row in Col A, where Col B contains a zero or blank
The macro takes a few mins to run and there is a maximum of 1000 rows
It would be appreciated if someone could kindly amend my code
Code:
Sub deleteRowsSummary()
Dim lastRow As Long
Dim i As Long
With Sheets("Summary")
.Unprotect
'Get the last row in column A
lastRow = Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Row
'Loop through rows 25 to last row in column B
For i = 25 To lastRow
If Sheets("Summary").Range("B" & i).Value = "" Or Sheets("Summary").Range("B" & i).Value = 0 Then
Sheets("Summary").Range("B" & i).EntireRow.Delete
i = i - 1 'since the row is deleted, need to decrement i to re-check the same row number
End If
Next i
.Protect
End With
End Sub