Hi.
I need to delete rows from a ListObject very fast, based on criteria applied on a date column.
I get the 1004 Delete method of Range class failed error on the EntireRow.Delete line:
First column of this table is of type Date and has valid dates in it.
Here's how I call this sub:
Any ideas?
Thanks!
I need to delete rows from a ListObject very fast, based on criteria applied on a date column.
I get the 1004 Delete method of Range class failed error on the EntireRow.Delete line:
Code:
Sub DeleteOldPhoneCalls(ByRef tblCalls As ListObject)
Dim rngDelete As Range
tblCalls.Range.AutoFilter Field:=1, Criteria1:="<" & Now() - Range("Days_to_Keep_Phone_Calls").Value
Set rngDelete = tblCalls.Range.SpecialCells(xlCellTypeVisible)
tblCalls.Range.AutoFilter
If Not rngDelete Is Nothing Then rngDelete.EntireRow.Delete
Set rngDelete = Nothing
End Sub
First column of this table is of type Date and has valid dates in it.
Here's how I call this sub:
Code:
Dim tblCalls As ListObject
Set tblCalls = Sheets("Calls Table").ListObjects("PhoneCallsTable")
Call DeleteOldPhoneCalls(tblCalls)
Any ideas?
Thanks!