I have a large data table where I want to delete the row with the oldest date. The code I use to delete around 900 rows out of 35.000 lasts forever:
Dim sht As Worksheet
Set sht = Workbooks(ActiveWorkbook.Name).Worksheets("Sheet")
Dim tbl As ListObject
Set tbl = sht.ListObjects("Table")
' looking for the oldest day
Set c = Range("A1:a" & Rows.count)
date_to_delete = Application.WorksheetFunction.Min(c)
'loop to delete rows
For rw = tbl.DataBodyRange.Rows.Count To 1 Step -1
If tbl.DataBodyRange(rw, 1) = date_to_delete Then
tbl.ListRows(rw).Delete
End If
Next rw
Any idea how to speed this up ? It takes like 5 min now ...