Filter on today...how possible?

W

wietse.uitenbroek

Hi all,

In the below VBA code I want to filter on Today. To do so I place
today's date in a cell and copied that with the filtering.
Unfortunately in the code 30/03/07 is places. Can somebody tell me how
I could fix this?
Thanks in advance,

Wietse

VBA code:
Range("F26").Select
ActiveCell.FormulaR1C1 = "=TODAY()"
Range("B28:F28").Select
Range(Selection, Selection.End(xlDown)).Select
Range("B28:F300").Select
Selection.AutoFilter
ActiveWindow.SmallScroll Down:=-12
Range("F26").Select
Selection.Copy
Selection.AutoFilter Field:=5, Criteria1:="<30/03/07",
Operator:=xlAnd
 
W

wietse.uitenbroek

Problem is that there is a smaller then sign before and using the code
you mentioned with a smaller sign before doens't work....any
suggestions?
 
D

Dave Peterson

maybe...
Selection.AutoFilter Field:=5, Criteria1:="<" & format(date, "dd/mm/yy"), ...
 
W

wietse.uitenbroek

Thanks but it doesn't seems to work. When useing the code you
mentioned the filter uses a other value and nothing is filtered out.
Other ideas?
 
D

Dave Peterson

Working with dates and autofilter can be troublesome. Sometimes you have to
experiment.

Selection.AutoFilter Field:=5, Criteria1:="<" & clng(date), ...

If this doesn't work...
Are you sure that that field is formatted as dd/mm/yy?

If it's not, then use the format that you use in this line:
Selection.AutoFilter Field:=5, Criteria1:="<" & format(date, "mm/dd/yyyy"), ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top