PatrickW1907
New Member
- Joined
- Sep 3, 2022
- Messages
- 18
- Office Version
- 365
- Platform
- Windows
Hi Guys,
I'm hoping someone can help.
I have over 10k rows of data.
A list of dates in column E (uk format i.e. dd/mm/yyyy)
I want to delete any row (except for header) that does not have yesterdays date. I have tried doing Date-1 and then I have tried to get a cell value after i put a formula to get yesterdays date then copied and pasted values into AI1. As I have over 10K data I am trying to do the quickest way possible as For Loops and IFs take an age to run.
The closest I get is the following code
At the moment I get the error runtime error 1004 : Method range of object - 'Global' failed but I also have had named object error.
Any help is appreciated.
I'm hoping someone can help.
I have over 10k rows of data.
A list of dates in column E (uk format i.e. dd/mm/yyyy)
I want to delete any row (except for header) that does not have yesterdays date. I have tried doing Date-1 and then I have tried to get a cell value after i put a formula to get yesterdays date then copied and pasted values into AI1. As I have over 10K data I am trying to do the quickest way possible as For Loops and IFs take an age to run.
The closest I get is the following code
VBA Code:
Sub Test6()
Worksheets("Sheet1").Activate
Range("AI1").Formula = "=TODAY()-1"
Range("AI1").Copy
Range("AI1").PasteSpecial xlPasteValues
With ActiveSheet
.Range("A:AH").AutoFilter
.AutoFilter Field:=5, Criterial:=Range("<>AI1").Value
.Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
.AutoFilter
End With
End Sub
At the moment I get the error runtime error 1004 : Method range of object - 'Global' failed but I also have had named object error.
Any help is appreciated.
Last edited by a moderator: