Consulting

Results 1 to 2 of 2

Thread: autofilter problem

  1. #1
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location

    autofilter problem

    Hello,

    In my code I have :-

    [vba]With Worksheets("GBP")

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

    End[/vba]
    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I tend to use

    [vba]

    .Range("$A$1:$G$25000").AutoFilter Field:=1, Criteria1:= _
    ">=" & Format(StartFilterStart, .Range("$A$2).Numberformat), Operator:=xlAnd, Criteria2:="<=" & Format(StartFilterEnd, .Range("$A$2).Numberformat)
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •