+ Reply to Thread
Results 1 to 3 of 3

VBA MACRO Autofilter by date reference

  1. #1
    Registered User
    Join Date
    12-08-2012
    Location
    Cape Girardeau, MO
    MS-Off Ver
    Excel 2003
    Posts
    5

    Smile VBA MACRO Autofilter by date reference

    I have a MACRO to activate an open workbook, copy the data, and paste it into my main workbook.

    To save space i would like to trim the data down (has roughly 20k lines of data) that i want to copy over by a specific date range.
    The reference is based off of a user input value in a specific cell that the user can change for a different date range.
    This reference is located in workbook "safety challenge report" sheets "imsot" range("r4") (for the from date)
    and the same workbook and sheet but range("s4") (for the to date).

    The raw data format starts with the date in column A then has more corresponding data for 11 columns in total A:K

    IN VBA:
    ‘THIS SECTION WORKS FINE- IT HUNTS FOR THE SPECIFIC OPEN WORKBOOK I WANT TO COPY THE RAW DATA FROM. (I KNOW I CAN DO AN AUTOFILTER, THEN COPY HERE… BUT I CAN’T FIGURE OUT HOW TO IDENTIFY MY RANGE OF DATES THAT ARE REFERENCED IN MY MAIN WORKBOOK…

    Please Login or Register  to view this content.

    'THANK YOU SO MUCH, I HOPE I MADE THIS THE EASIEST TO UNDERSTAND. I'm trying to avoid sensitive information so I did not attach the actual file. please let me know if you have any questions!
    Last edited by jeffreybrown; 07-15-2020 at 03:15 PM. Reason: Please use code tags!

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 2016 (Windows)
    Posts
    5,060

    Re: VBA MACRO Autofilter by date reference issue- help :)

    This is how you would filter using named ranges that contain the dates of interest:

    Please Login or Register  to view this content.
    The above assumes the named ranges are in the activeworkbook - otherwise the ranges need to be fully specified along the lines of this:
    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 07-15-2020 at 04:58 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    12-08-2012
    Location
    Cape Girardeau, MO
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: VBA MACRO Autofilter by date reference

    THANKS!

+ 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. Macro to set Autofilter AFTER today's date
    By anudeepraj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-31-2015, 10:04 AM
  2. Replies: 4
    Last Post: 03-16-2013, 08:33 AM
  3. [SOLVED] Autofilter - Macro to Return Value in Userform Field based upon Most Recent Date
    By Southfish in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-01-2012, 12:57 AM
  4. Replies: 2
    Last Post: 07-06-2012, 11:42 AM
  5. Cell reference from another sheet in autofilter macro
    By feddon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2011, 05:45 AM
  6. Macro, autofilter, delete rows outside date range, defined names as criteria
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-30-2011, 04:10 AM
  7. Macro to AutoFilter based on current date
    By JimmyA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-24-2008, 05:44 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