PDA

View Full Version : autofilter problem



philfer
08-27-2010, 02:14 PM
Hello,

In my code I have :-

With Worksheets("GBP")

.Rows("1:1").AutoFilter
.Range("$A$1:$G$25000").AutoFilter Field:=1, Criteria1:= _
">=" & StartFilterStart, Operator:=xlAnd, Criteria2:="<=" & StartFilterEnd

End
If I do debug.print for StartFilterStart and StartFilterEnd I get :-

01/09/2010
30/09/2010

As I use DateAdd to get the start and end of a month

However the autofilter filters on between :-

09/01/2010
30/09/2010

My system date is UK

Does anyone know why this is happening?

Thanks
Phil

Bob Phillips
08-27-2010, 02:55 PM
I tend to use



.Range("$A$1:$G$25000").AutoFilter Field:=1, Criteria1:= _
">=" & Format(StartFilterStart, .Range("$A$2).Numberformat), Operator:=xlAnd, Criteria2:="<=" & Format(StartFilterEnd, .Range("$A$2).Numberformat)