Hi
I'm using this Sub to delete rows where the number zero exists in column B.
However, if the Sub has already been run and the rows with the number zero in column B have been deleted, then the Sub produces an error.
Does anyone know how to exit the Sub IF there are no rows in column B with a zero value?
Please find below some simple sample data (for columns A and B):
I'm using this Sub to delete rows where the number zero exists in column B.
However, if the Sub has already been run and the rows with the number zero in column B have been deleted, then the Sub produces an error.
Does anyone know how to exit the Sub IF there are no rows in column B with a zero value?
Please find below some simple sample data (for columns A and B):
1 | 4 |
2 | 5 |
3 | 6 |
VBA Code:
Sub DeleteRows
With ActiveSheet
.Range("B1:B70").Autofilter 2, "0"
.Autofilter.Range.Offset(1).EntireRow.Delete
.Automodefilter = false
End With
End Sub