Deleting entire rows based on certain criteria

  • Thread starter Thread starter Nan
  • Start date Start date
N

Nan

Is there a way to automatically delete any row that has a 0 in both of
specified columns (i.e. BF and BG)?

Thanks for any help
 
Hi
try the following macro:
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index, "BF").Value= 0 and _
Cells(row_index, "BG").Value= 0 then
Rows(row_index).delete
End If
Next
Application.ScreenUpdating = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top