Hello everyone,
I have a macro which I want to filter data against a date which the user enters then delete the visible rows however when I run this, it doesn't return anything in the filter so I think it is not recognising the criteria as a date. Any ideas on how to resolve this?
Thanks for your help!!
Sub Delete_old()
Dim CutOffDate As Date
CutOffDate = Application.InputBox("Enter the cut off date in the Format ""DD/MM/YYYY""")
Selection.AutoFilter
Selection.AutoFilter Field:=17, Criteria1:="<=" & CutOffDate
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Range("A1").Select
End Sub
I have a macro which I want to filter data against a date which the user enters then delete the visible rows however when I run this, it doesn't return anything in the filter so I think it is not recognising the criteria as a date. Any ideas on how to resolve this?
Thanks for your help!!
Sub Delete_old()
Dim CutOffDate As Date
CutOffDate = Application.InputBox("Enter the cut off date in the Format ""DD/MM/YYYY""")
Selection.AutoFilter
Selection.AutoFilter Field:=17, Criteria1:="<=" & CutOffDate
Rows("2:2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter
Range("A1").Select
End Sub