Macro that will Delete Rows with 0,8,9 in it

  • Thread starter Thread starter Steved
  • Start date Start date
S

Steved

Hello from Steved.

Please I need a macro to do the following
If 0 value in a cell delete the entire row
If 8 value in a cell delete the entire row
If 9 value in a cell delete the entire row
or VBA.

Thankyou.
 
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, "A").Value =0 or _
Cells(row_index, "A").Value =8 or _
Cells(row_index, "A").Value =9 then
Cells(row_index, "A").EntireRow.delete
End If
Next
Application.ScreenUpdating = True
End Sub
 
Thankyou.
-----Original Message-----
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, "A").Value =0 or _
Cells(row_index, "A").Value =8 or _
Cells(row_index, "A").Value =9 then
Cells(row_index, "A").EntireRow.delete
End If
Next
Application.ScreenUpdating = True
End Sub

.
 
Back
Top