+ Reply to Thread
Results 1 to 4 of 4

Macro to set Autofilter AFTER today's date

  1. #1
    Registered User
    Join Date
    06-12-2015
    Location
    Hyderabad, India
    MS-Off Ver
    2013
    Posts
    2

    Macro to set Autofilter AFTER today's date

    Hi there!

    I'm a VBA noob, taking my first steps. I'm unable to figure out how to set Autofilter to filter out the dates after today (but include today's date).

    This is my code:

    ActiveSheet.Range("$A$1:$AB$10000").AutoFilter Field:=2, Criteria1:=">" & Date, Operator:=xlAnd

    This code runs fine but it excludes today's date which I need.

    Any help would be appreciated.


    Thanks!

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to set Autofilter AFTER today's date

    Try:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-12-2015
    Location
    Hyderabad, India
    MS-Off Ver
    2013
    Posts
    2

    Re: Macro to set Autofilter AFTER today's date

    Thanks John! Unfortunately it gives me the same data as before.

    However, I just tried manually applying Autofilter and saw that Excel takes today's date when applying 'is after' filter, which is strange.

    I modified my code to this:

    ActiveSheet.Range("$A$1:$AB$10000").AutoFilter Field:=2, Criteria1:=">" & Date + 1, Operator:=xlAnd

    and it works perfect! Thanks for your help again!

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to set Autofilter AFTER today's date

    Hmm. Strange indeed. Code I suggested worked when I tested it. Note Operator xlOr.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. RE: VBA Macro Needs Tweaking to Delete Rows Where Date As String is Less Than Today's Date
    By justinbelkin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-05-2013, 04:54 PM
  2. Need Macro Date Help not based on Today's Date
    By Sally_Shell in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-19-2011, 08:57 PM
  3. Need Macro Date Help not based on Today's Date
    By Sally_Shell in forum Excel General
    Replies: 1
    Last Post: 05-18-2011, 08:22 PM
  4. AutoFilter for any cell between =today() and =today()+14??
    By kpratico in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-01-2010, 04:36 PM
  5. Today date plus macro answer
    By johncena in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-17-2010, 12:06 PM
  6. Macro for doing a date stamp that isn't today
    By Plaasboy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-27-2008, 09:55 AM
  7. create a macro to alert me if today's date is within 5 days of expected delivery date
    By ashmcclure in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 09-25-2008, 05:51 PM
  8. AutoFilter, using "Today's Date"
    By Blobbies in forum Excel General
    Replies: 4
    Last Post: 01-29-2006, 02:00 AM

Tags for this Thread

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