This should be dynamic now so if your data goes past 25k rows.
Sub Works()
'
' Macro3 Macro
'
'
Application.ScreenUpdating = False
Range("O2").Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[-12]>=(TODAY()+CHOOSE(WEEKDAY(TODAY()),-3,-4,-5,-6,0,-1,-2)),RC[-12]<=TODAY(),ISNUMBER(FIND(""AUTO"",RC[-7]))),""yes"",""no"")"
Range("O2").Select
Selection.AutoFill Destination:=Range("O2:O" & Range("A" & Rows.Count).End(xlUp).Row)
Columns("O:O").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Call Delete
Columns("O:O").Select
Selection.Delete Shift:=xlToLeft
Application.Goto Range("A1"), Scroll:=True
Range("A1").Select
Application.ScreenUpdating = True
End Sub
Sub Delete()
Dim LastRow As Long
Dim i As Long
Dim rng As Range
Dim deleteRange As Range
' Find the last cell with a value in column O
Set rng = Range("O1", Range("O" & Rows.Count).End(xlUp))
LastRow = rng.Row + rng.Rows.Count - 1
' Loop through the rows in reverse order
For i = LastRow To 1 Step -1
If Range("O" & i) = "yes" Then
If deleteRange Is Nothing Then
Set deleteRange = Range("O" & i)
Else
Set deleteRange = Union(deleteRange, Range("O" & i))
End If
End If
Next i
' Delete the rows
If Not deleteRange Is Nothing Then
deleteRange.EntireRow.Delete
End If
End Sub
Bookmarks