This is the macro that I have been using. Initially I had it just removing the rows if the cell was blank or zero. Since then I changed it to delete the row for other values.
Application.ScreenUpdating = False
Dim Rng As Range
Dim c As Range
Set Rng = Range("A9:A509")
For Each c In Rng
If c.Value = 0# Then
c.EntireRow.Delete xlShiftUp
End If
Next c
For Each c In Rng
If c.Value = "1" Then
c.EntireRow.Delete xlShiftUp
End If
Next c
For Each c In Rng
If c.Value = "BR1" Then
c.EntireRow.Delete xlShiftUp
End If
Next c
So two questions:
First, it does not remove all the rows the first time. If there are multiple rows with a cell containing BR1, it may remove the first six, but leave the last one or two. Running the macro once or twice more will remove these extra rows. Why is this occurring?
The second question, since the purpose has change, I would rather the macro remove all rows when the cells A9 through A509 contain a value other than PR1. Is there a quicker way than what I have above?
Thanks
Application.ScreenUpdating = False
Dim Rng As Range
Dim c As Range
Set Rng = Range("A9:A509")
For Each c In Rng
If c.Value = 0# Then
c.EntireRow.Delete xlShiftUp
End If
Next c
For Each c In Rng
If c.Value = "1" Then
c.EntireRow.Delete xlShiftUp
End If
Next c
For Each c In Rng
If c.Value = "BR1" Then
c.EntireRow.Delete xlShiftUp
End If
Next c
So two questions:
First, it does not remove all the rows the first time. If there are multiple rows with a cell containing BR1, it may remove the first six, but leave the last one or two. Running the macro once or twice more will remove these extra rows. Why is this occurring?
The second question, since the purpose has change, I would rather the macro remove all rows when the cells A9 through A509 contain a value other than PR1. Is there a quicker way than what I have above?
Thanks