+ Reply to Thread
Results 1 to 3 of 3

Setting autofilter at runtime

  1. #1
    AD108
    Guest

    Setting autofilter at runtime

    Hello,

    I am trying to set an autofilter to a custom filter when a user clicks
    command button. The code I have linked to the button follows. The goal is
    to get the autofilter to return rows where the date in the field is less
    than or equal to today. I think I can see that the problem is that the code
    is seeing the string ">=Now" as a literal string without evaluting the
    expression within it.

    Dim lDate As Date
    Selection.AutoFilter Field:=12, Criteria1:="<= Now", Operator:=xlAnd
    End Sub

    Any help would be greatly appreciated.



  2. #2
    Ardus Petus
    Guest

    Re: Setting autofilter at runtime

    Selection.AutoFilter Field:=12, Criteria1:="<=" & Now

    HTH
    --
    AP

    "AD108" <arielNOSPAM@downtoearth.org> a écrit dans le message de news:
    O2c40pUhGHA.4404@TK2MSFTNGP05.phx.gbl...
    > Hello,
    >
    > I am trying to set an autofilter to a custom filter when a user clicks
    > command button. The code I have linked to the button follows. The goal
    > is
    > to get the autofilter to return rows where the date in the field is less
    > than or equal to today. I think I can see that the problem is that the
    > code
    > is seeing the string ">=Now" as a literal string without evaluting the
    > expression within it.
    >
    > Dim lDate As Date
    > Selection.AutoFilter Field:=12, Criteria1:="<= Now", Operator:=xlAnd
    > End Sub
    >
    > Any help would be greatly appreciated.
    >
    >




  3. #3
    AD108
    Guest

    Re: Setting autofilter at runtime

    Thanks,
    That made it work.

    "Ardus Petus" <ardus.petus@laposte.net> wrote in message
    news:e4N$WwUhGHA.836@TK2MSFTNGP02.phx.gbl...
    > Selection.AutoFilter Field:=12, Criteria1:="<=" & Now
    >
    > HTH
    > --
    > AP
    >
    > "AD108" <arielNOSPAM@downtoearth.org> a écrit dans le message de news:
    > O2c40pUhGHA.4404@TK2MSFTNGP05.phx.gbl...
    > > Hello,
    > >
    > > I am trying to set an autofilter to a custom filter when a user clicks
    > > command button. The code I have linked to the button follows. The goal
    > > is
    > > to get the autofilter to return rows where the date in the field is less
    > > than or equal to today. I think I can see that the problem is that the
    > > code
    > > is seeing the string ">=Now" as a literal string without evaluting the
    > > expression within it.
    > >
    > > Dim lDate As Date
    > > Selection.AutoFilter Field:=12, Criteria1:="<= Now", Operator:=xlAnd
    > > End Sub
    > >
    > > Any help would be greatly appreciated.
    > >
    > >

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1