+ Reply to Thread
Results 1 to 10 of 10

Open the latest file in a folder, and the second latest - up till the tenth latest saved

  1. #1
    Registered User
    Join Date
    06-12-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    6

    Smile Open the latest file in a folder, and the second latest - up till the tenth latest saved

    Hi guys.

    I have a problem that I really hope somebody can solve.

    I need a macro that can open 1 of the 10 latest saved files (XLS, XlSX, XLSM) in a folder.

    For example if I need to open the third last file, I would like to able to write that or choose a cell in the workbook wich would give me the information, so the macro knows wich file it should take.

    I have the macro for opening the latest saved file, which I search the internet for. But I cant find anything to solve my current problem.
    open-the-latest-file-in-a-folder.xlsm

    I hope it's possible and someone can help me

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Open the latest file in a folder, and the second latest - up till the tenth latest sav

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    06-12-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Open the latest file in a folder, and the second latest - up till the tenth latest sav

    Thank you so much, this works! I just have a problem changing wich file to open, how do you chance from 3 to 5 or 7?

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Open the latest file in a folder, and the second latest - up till the tenth latest sav

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-12-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Open the latest file in a folder, and the second latest - up till the tenth latest sav

    Thank you!
    There is still a little problem. It can not open from other months than the current.

    I have a folder with files from every week: week1.xls -> week24.xls

    If i change the numfile to 5 or 10, it just takes the first file from this month week23.xls.

    But it works from numfile 1 to 3, I just need to go further back.

  6. #6
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Open the latest file in a folder, and the second latest - up till the tenth latest sav

    it's not very clear for me

  7. #7
    Registered User
    Join Date
    06-12-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Open the latest file in a folder, and the second latest - up till the tenth latest sav

    If you have a folder with files from previous months, you can try it out and see?

  8. #8
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Open the latest file in a folder, and the second latest - up till the tenth latest sav

    I think so

  9. #9
    Registered User
    Join Date
    06-12-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Open the latest file in a folder, and the second latest - up till the tenth latest sav

    If set numfile to 5, it will not take the file that is the fifth newest. it takes the first file from this month.

  10. #10
    Registered User
    Join Date
    02-17-2012
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Open the latest file in a folder, and the second latest - up till the tenth latest sav

    Hi There,

    Hoping that anyone can help me

    I'm trying to extract the second latest file within a folder, without generating the two lists as the script above does.

    I'd just like the macro to open the second latest file - can this be done?

    Many thanks!
    Guy

  11. #11
    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: Open the latest file in a folder, and the second latest - up till the tenth latest sav

    Hello guydixon,

    In the future, please start a new thread. You are not supposed to post a new question in another person's thread. Include a link to the post in your question.

    Here is a macro to extract the latest Excel files (.xls, .xlsb, .xlsm, ..xlsx) from a folder. There is an example macro to open the second latest modified Excel file in the folder.

    Please Login or Register  to view this content.
    Example to Open the Second Latest File
    Please Login or Register  to view this content.
    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!)

+ 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