+ Reply to Thread
Results 1 to 4 of 4

VBA to filter data by date

  1. #1
    Registered User
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    48

    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
    2013 / 2016 / 365
    Posts
    6,436

    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
    Registered User
    Join Date
    07-21-2018
    Location
    London, England
    MS-Off Ver
    Excel for Mac Version 16.15
    Posts
    48

    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
    2013 / 2016 / 365
    Posts
    6,436

    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)

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