+ Reply to Thread
Results 1 to 3 of 3

Macro to open latest file within a folder

  1. #1
    Registered User
    Join Date
    12-15-2010
    Location
    Oregon, USA
    MS-Off Ver
    Excel 2007
    Posts
    48

    Macro to open latest file within a folder

    Hi Guys,
    I have case where there are excel files arranged like this within a folder. For example:-

    XA11_df01.xlsx
    XA11_df02.xlsx
    XA11_df03.xlsx
    .
    .
    XB11_df01.xlsx
    XB11_df02.xlsx
    .
    .
    YA11_df01.xlsx
    YA11_df02.xlsx
    .
    .
    YB11_df01.xlsx
    YB11_df02.xlsx
    .
    .

    All these files are located in one folder. I want to write a macro to open the latest excel files based on lastmodified date and time for each file name like XA11, XB11, YA11, YB11. I only want to do this for excel files (".xlsx") within a folder as there are other pdf files also in the folder. I want macro to open the latest file for first file name run my code on it , then open latest file for second file name and run my code on it so on.


    Any help will be highly apprecited.

    Thanks.
    Roop
    Last edited by Roop; 01-21-2011 at 10:30 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro to open latest file within a folder

    Hello Roop,

    This macro will open the most recent ".xlsx" file in the given directory based on the file name to left of the underscore. You will need to change the file path and add a call to your macro in this one. At the bottom you will see a comment (in bold text). This is where you need to add the call.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 01-23-2011 at 02:44 AM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-23-2012
    Location
    philadelphia, USA
    MS-Off Ver
    2007
    Posts
    1

    Re: Macro to open latest file within a folder

    Thanks Leith.

+ 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