I am using an AutoFilter with VBA in Excel that works for regular filters, but not a column formatted as date.
I can filter it manually. If I run my code, it filters nothing but when I check the filter and then only click ok (no change being applied to the filter criteria), it filters correctly.
Here is my code:
ws.ListObjects(SheetName).Range.AutoFilter Field:=3, Criteria1 _
:=">" & CDate([datecell]), Operator:=xlAnd, Criteria2:= _
"<=" & CDate(WorksheetFunction.EoMonth([datecell], 3))
It seems to be a common problem, but I have not found a solution.
When I run a recorded macro, it does not work either.
CDate([datecell])
change toFormat([datecell], "dd-MMM-yy")
[datecell]
andWorksheetFunction.EoMonth([datecell], 3)
if youDebug.Print
ormsgbox
them?