+ Reply to Thread
Results 1 to 4 of 4

VBA to filter data by date

  1. #1
    Forum Contributor
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    117

    VBA to filter data by date

    Hello!

    I have a sheet that contains details of club members with their join dates (col E) and date of their last visit (col B).

    I need some code that will filter out members that haven't visited in at least 2 months (or 61 days) from today's date - but also joined before then (to avoid including new joiners who don't haven't even visited for the first time yet).

    The data range is indefinite (as member numbers change all the time) so the code will need to find the last row.

    I have some existing code for another project that kind of filters by date so this could be used as a model but it's not specific to this purpose...

    Please Login or Register  to view this content.
    Please can someone help me out?

    Thank you!

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA to filter data by date

    Wouldn't a pivot table be easier? You can have a helper column to do the logic based on join date and last visit. Call it "good standing" and have it evaluate to True for new members and recent attenders. Then use this column as a filter on the pivot table.

    Also, I recommend you attach a sample file. People are more willing to work on an issue when they have something to work on.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    117

    Re: VBA to filter data by date

    Thanks for your reply! Unfortunately I do need to do it with vba. Basically our computer system generates this report as a .csv file and then I want to filter the data and copy it over to another workbook. So the user will generate the report, attach the file with an 'import data' button on the workbook and it will only copy over the relevant data.

    I have attached the .csv file and the second workbook so you can get the idea.

    Thanks!
    Attached Files Attached Files

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: VBA to filter data by date

    I had to dummy up the data to provide distinct account numbers. This worksheet imports the CSV file, puts it into a data table, runs a pivot table against that and then copies the pivot table to the report sheet. Run it off the control panel.

    Put the path to the CSV file in cell B1, and the name of the CSV file in cell B2. Click the button.
    Attached Files Attached Files

+ 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. VBA Filter data betwen start date and end date doesn't run on MS.Excel 2013
    By okido in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2017, 10:46 AM
  2. [SOLVED] Filter data by date
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-31-2016, 10:46 PM
  3. VBA : Filter data using today's date
    By Pradboule in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-02-2014, 12:16 PM
  4. Filter data by date (within 3 months of todays date)
    By Gti182 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-20-2014, 01:42 PM
  5. [SOLVED] Filter date by cell data
    By Petijandro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2014, 08:07 AM
  6. [SOLVED] VBA to filter data after a date
    By jonathan.haynes in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-07-2013, 06:45 AM
  7. Filter data with date
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-19-2012, 01:47 PM

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