Using VBA to delete certain worksheets rows

A

avilla

Hi everyone

I have a large worksheet that contains a large amount of records wit
the same values that are not relevant and need deleting. I am using th
following code that does not work.

Can anyone please help

Sub Macro2()
If ActiveCell = ("n/a") Then
EntireRow.Delete
End If
ActiveCell.Offset(1, 0).Select

End Sub

I would also like the macro to stop when it reaches a cell that doe
not contain any value

THANK YO
 
N

Norman Jones

Hi Avilla,

One way:

Sub Tester()
Dim Lastcell As Range
Dim i As Long

Application.DisplayAlerts = False

Set Lastcell = Cells(Rows.Count, "A")

For i = Lastcell.Row To 1 Step -1
If Cells(i, 1).Value = ("n/a") Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Application.DisplayAlerts = True
End Sub
 
Top