Sub Loop_Example()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
'Sheets("MySheet")if you want
With ActiveSheet
'Set the first and last row to loop through
Firstrow = 23 '<--start row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row '<--last used row in your workbook, could be any integer like Firstrow
'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1
'We check the values in the A column in this example
With .Cells(Lrow, "G")
If Not IsError(.Value) Then
If .Value <> "Yes" Then .EntireRow.Delete
'This will delete each row with the Value not equal to "Yes"
'in Column A, case sensitive.
End If
End With
Next Lrow
End With
End Sub
Bookmarks