How would I create an autofilter for items 3 days old

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to do an autofilter for items that are 3 days old. I have tried
several things, but the results are totally bogus...It shows only about 15
records (should be about 200) and there are blank records (which are not in
the worksheet??!!) and dates that are newer (as well as some that are older)
than the target date



Sub threedaysold()
'
' threedaysold Macro
' Macro recorded 8/28/2003 by Bruce
'

'
Cells.Select
Range("G1").Activate
Selection.AutoFilter Field:=9, Criteria1:="=today() - 3",
Operator:=xlAnd
End Sub
 
If you look at the Custom filter in the the date column, after you've
run this macro, you'll see that it's filtering for Date equals "=today()-3"

Calculate the date in the macro, and format it to match the date
formatting in the column. For example:

Sub threedaysold()
Range("G1").AutoFilter Field:=9, _
Criteria1:=Format(Date - 3, "m/d/yy")
End Sub
 
I am trying to get all dates equal to or before the date... ( I edited the
macro trying to get it to work, and I guess that part was not clear...)

Thanks
 
Thanks!!!
It works like a charm!

Debra Dalgleish said:
You can use the following:

Sub threedaysold()
Range("G1").AutoFilter Field:=9, _
Criteria1:="<=" & Format(Date - 3, "m/d/yy")
End Sub
 
Back
Top