Simple thing is not simple. I am trying to delete rows based on a specific column having data that begins with \"2L\". So I wrote this code (LastRow is understood):
Or use autofilter
Option Explicit
Public Sub CleanUp()
Dim lastRow As Long, testRange As Range
With ThisWorkbook.Worksheets("Sheet2")
lastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
Set testRange = .Range("F1:F" & lastRow)
If Application.WorksheetFunction.CountIf(testRange, "2L*") > 0 Then
With testRange
.AutoFilter
.AutoFilter Field:=1, Criteria1:="2L*", Operator:=xlFilterValues
.SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
End If
End With
End Sub