I have the following code that will delete every row that doesn't meet the specified criteria. However, when I run it, it deletes the header which is in row A1 thru Y1. Can you tell me what I need to put in this code to stop it before it gets to the header?
Sub DeleteRows()
Application.ScreenUpdating = False
Dim ws1 As Worksheet
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Set ws1 = ActiveSheet
With ws1
Firstrow = .UsedRange.Cells(2).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
For Lrow = Lastrow To Firstrow Step -1
With .Cells(Lrow, "x")
If .Value <> "4SK5" And .Value <> "4S52" Then .EntireRow.Delete
End With
Next Lrow
End With
Application.ScreenUpdating = True
End Sub
Any help would be appreciated.
Bookmarks