+ Reply to Thread
Results 1 to 4 of 4

Open files within date range

  1. #1
    Registered User
    Join Date
    02-08-2012
    Location
    manila, philippines
    MS-Off Ver
    Excel 2003
    Posts
    9

    Open files within date range

    Hello everyone,

    I have a set of excel files that I needed opened then a subsequent macro will take place. The files are labeled like so "date Master" (e.g. 05-17-2016 Master). For the most part I do not have gaps on filing system so theoretically by the end of the year I'd have 365 files in that particular folder. Not sure if pertinent to the process but I figured to give out full disclosure.

    I'd need to have a macro to open files from last Friday's date through the file that is dated 30 days prior to (if that makes sense ) that would compile the sheets into 1. To further elaborate since I think my description is clear as mud this would be the concept of the process:

    If I run the report today, 5/17/2016 or any time this week for that matter, with last friday's date being 5/13/2016, the report the macro would open file 04-16-2016 Master, copies the data into destination sheet, close, then open 04-17-2016 Master,copies the data into destination sheet, close, then open 04-18-2016......until it opens 05-13-2016 Master, copies the data into destination sheet, then closes thus ending the loop

    I have bits and pieces of the information that I need but I can seem to put them together to have a cohesive code. Here's what I have so far which is pretty much a dud

    Please Login or Register  to view this content.
    Thanks for any help!

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

    Re: Open files within date range

    This is the way I'd do it. I'd also add some checks in the copying code to check if the file exists, just in case there are gaps.
    Please Login or Register  to view this content.
    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
    02-08-2012
    Location
    manila, philippines
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Open files within date range

    This worked beautifully and exactly how I imagined and needed it to function. Thank you! So I did encounter a file name gap. How would I incorporate that into the macro? I know error handlers exist but no idea how that works.

    Thank you!

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

    Re: Open files within date range

    Here's a simple test to see if a file exists. Wrap your code in an if statement. This function returns TRUE if the file exists and FALSE if it doesn't.
    Please Login or Register  to view this content.

+ 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 open files and copy specific sheet into new workbook (have open files part)
    By dangerdavedsp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-04-2015, 02:23 PM
  2. VBA to open WINSCP and copy files based on date created
    By DanzaNZ in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-19-2014, 11:31 PM
  3. macro to copy range into open files
    By ammartino44 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-22-2014, 05:07 PM
  4. [SOLVED] Macro to open files with diffrent date format
    By suyogpatil in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-28-2013, 07:10 AM
  5. Open all workbooks within date range
    By nipthedog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2012, 06:02 PM
  6. Replies: 2
    Last Post: 10-13-2012, 02:12 PM
  7. [SOLVED] Open all files in a SharePoint folder (Problem: Files open out of order)
    By holmstarrunner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2012, 10:13 AM

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