Another way (uses no loops)...
Code:
Sub DeleteThreesAndTargets()
Dim LastRow As Long, UnusedColumn As Long
LastRow = Cells(Rows.Count, "C").End(xlUp).Row
UnusedColumn = Cells.Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, LookIn:=xlFormulas).Column
With Range(Cells(1, UnusedColumn), Cells(LastRow, UnusedColumn))
.Value = Evaluate("IF((C1:C" & LastRow & "=3)*(AA1:AA" & _
LastRow & "=""target""),C1:C" & LastRow & ","""")")
On Error Resume Next
.SpecialCells(xlConstants).EntireRow.Delete
On Error GoTo 0
End With
End Sub
This method does have a restriction of no more than 8192 individual ranges (areas) of rows (contiguous rows count as one area) meeting your conditions for deletion. That means you can have at least 16394 rows of data before the code might give you trouble.
Bookmarks