+ Reply to Thread
Results 1 to 2 of 2

Open a file in the most recent folder

  1. #1
    Registered User
    Join Date
    09-10-2012
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2010
    Posts
    1

    Open a file in the most recent folder

    Hello All.

    I need some help with a macro to open specific file within the newest folder in another folder.

    The source file is titled source.xls. It is located at R:\Reports\1302\26. R:\Reports is constant. However, each month the next folder name is changed to reflect the current year and month. For example, the next folder will be R:\Reports\1303. Next, the \26 folder will change daily as it reflects the day the last set of reports were run. So, to try and clear it up, I will open the following report today R:\Reports\1302\26\source.xls and then I'll open R:\Reports\1302\27\source.xls tomorrow, and so on.

    I hope this makes sense. Once the folder is open I can copy the data from the source file and put it into the file I want, but I just don't know how to open the most recent source.xls file. If there's a better way to accomplish opening the most recent source.xls file, please let me know.

    I am using Windows 7 and Excel 2010.

    Any help is greatly appreciated.

    Thanks!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,630

    Re: Open a file in the most recent folder

    If it were me, and I know it's not, I'd just create all the files in one folder and then incorporate the date into the file name. For example, Source 130226.xls.

    But, either way, you need to build the location of the file. So, it could be: "C:\Report\" & Application.WorksheetFunction.Text(Date, "yymm") & "\" & Application.WorksheetFunction.Text(Date, "dd") "\source.xls"


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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