This is more for the benefit of my British & European chums:
When providing a date to autofilter via VBA you must put it in American order. This I think, is because of the way Excel converts the date to a string to put it into the filter 'behind the scenes' (hence not localised properly).
This wasn't working:
Although the autofilter created looked like it ought to work, indeed recreating the exact same filter manually did work. I found that as the date was > 12 the month & date were effectively coerced into the right place. When I changed the maths to return a day of month less than 12 I saw that the day & month swapped in the custom filter created.with range... .AutoFilter 11, ">" & Date - 60
This does work (showing my thought process):
which can be tidied up:.AutoFilter 11, ">" & Month(Date - 60) & "/" & Day(Date - 60) & "/" & Year(Date - 60)
HTH.AutoFilter 11, ">" & Format(Date - 60, "mm/dd/yyyy")
CC
If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.
Try converting the date to a Long
with range... .AutoFilter 11, ">" & CLng(Date) - 60
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks