+ Reply to Thread
Results 1 to 2 of 2

Code to auto filter three month segments of data from today's date

  1. #1
    Registered User
    Join Date
    05-25-2011
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    52

    Code to auto filter three month segments of data from today's date

    I am trying to create a macro that will filter a column to include values that are within three months of today, six months of today, and a year of today. How I have been doing this is defining an array to contain my dates criteria like shown below. Then I run a loop that filters for criteria1 of dates(i) and criteria2 of dates(i+6). (btw I'm sure that this is a very inefficient way to do this, but I'm an amateur and I do what I can).This works if the date segments are stationary. But now I need the segment to change as today's date changes. So if today is July 1, I want to capture april-june after the macro runs. If it is July 17, I need it to capture April 17 - July 17. Any suggestions on how to do this. Currently my criteria are stings, so I can't "subtract" 3 months from today as far as I know. Example code or even just pointers on how to do this are appreciated. Thanks.

    Please Login or Register  to view this content.
    Last edited by gryffin13; 07-18-2012 at 09:10 AM.

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Code to auto filter three month segments of data from today's date

    Why not just put a "helper" column in your data with a formula to calculate a month difference between the two dates, then filter on the helper column? No code needed.
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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