Hi,
So the code so far works for smaller chunks of data but for data containing 500,000 rows of data, it takes over 3 hours to compile. I was wondering if the following line would make it faster to compile by selecting 10,000 rows at oncea and copying and pasting.
Sub Final_Cleanup()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False
Application.EnableEvents = False
Dim StartDate As Date, EndDate As Date
Dim i As Long
StartDate = DateSerial(Year(Date - 20), Month(Date - 20), Day(Date - 20))
EndDate = DateSerial(Year(Date), Month(Date), Day(Date))
On Error Resume Next
'Sheets("Archive").Delete
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Archive"
n Error GoTo 0
With Worksheets("Invoice")
For i = .Cells(.Rows.Count, 1).End(xlUp).Row To 10000 Step-1
If IsDate(.Cells(i, 1)) Then
If CLng(.Cells(i, 1).Value) < CLng(StartDate) Then
.Rows(i).Copy Destination:=Worksheets("Archive").Cells(Rows.Count, 1).End(xlUp).Offset(1)
.Rows(i).Cells.Clear
End If
End If
Next i
End With
Application.ScreenUpdating = True
ication.Calculation = xlCalculationAutomatic
on.DisplayAlerts = True
Application.EnableEvents = True
Exit Sub
End Sub
Does the line
For i = .Cells(.Rows.Count, 1).End(xlUp).Row To 10000 Step-1
work for selecting 10,000 rows at once and then copying it to the Archive Workheet?
Thanks in advance