Hi there I am trying to write a macro that processes a huge file (talking 30-35k rows). I have a loop that goes through all the cells in column A
and deletes all rows where the date in column A
doesn't equal yesterday's date. (sounds convoluted I know). Is there any more efficient way of doing this? I mean the loop works but it frequently crashes excel and times out etc.
Sub PSAudit()
Dim Auditdate As String
Dim rng As Range
Dim psm as worksheet
Set psm = Sheets("PS_MAIN")
Application.ScreenUpdating = False
Auditdate = Format(Date - 1, "yyyy-mm-dd")
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For x = 1 To lastrow
If psm.Range("A" & x).Value <> Auditdate Then psm.Range("A" & x).EntireRow.Delete
Next x
Application.ScreenUpdating = True
End Sub