+ Reply to Thread
Results 1 to 5 of 5

Formula to browse a specific folder, and return (display) the file with highest number???

  1. #1
    Forum Contributor
    Join Date
    07-22-2009
    Location
    Minneapolis, MN
    MS-Off Ver
    2016
    Posts
    220

    Formula to browse a specific folder, and return (display) the file with highest number???

    I'm not sure if this is even possible; but if anyone were to know, it'd be you folks!


    I have a specific folder (C:\xxx\xxx\xxx\Folder) that contains several .xlsm files (among other types).

    The last 6 characters of each filename is a number (IE: TEST_NAME 010203.xlsm, TEST_NAME 011403.xlsm, TEST_NAME 112112.xlsm, etc)



    I'm looking for a formula that will search within that specific folder; determine which ".xlsm" file has the highest last 6 characters, and display those characters in the cell.



    Is that even possible with a formula? If not, would it be possible wtih VBA?

    Thanks for any light you can shed!

  2. #2
    Registered User
    Join Date
    04-12-2013
    Location
    Dresden, Germany
    MS-Off Ver
    Excel 2013
    Posts
    10

    Re: Formula to browse a specific folder, and return (display) the file with highest number

    I doubt the possibility to do it with formulas, but it is not my style to say it is not possible. Here is a code how you could do it with a macro. Note that the code loops now through all the files in the folder.
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-22-2009
    Location
    Minneapolis, MN
    MS-Off Ver
    2016
    Posts
    220

    Re: Formula to browse a specific folder, and return (display) the file with highest number

    Hi,
    I figured it was a long shot via formula, but it was worth a shot. VBA it is...

    I tried the code you posted, and it seems to only return the value of 0.

    Perhaps we might be able to simply things a bit then...


    Say I change up the folder so that there is only one .xlsm file in the folder, and I wanted to paste that filename (filename only) in cell A1. How would I type that up?

  4. #4
    Registered User
    Join Date
    04-12-2013
    Location
    Dresden, Germany
    MS-Off Ver
    Excel 2013
    Posts
    10

    Re: Formula to browse a specific folder, and return (display) the file with highest number

    You may debug the code by setting a break point and check, if the variable file stays null. I guess that the backslash after the directory is missing therefore it doesn't find any files and returns 0.
    It must be C:\xxx\xxx\xxx\Folder\.
    If you have just one file in the folder and want to paste the whole name in cell A1, then the code would be something like
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-22-2009
    Location
    Minneapolis, MN
    MS-Off Ver
    2016
    Posts
    220

    Re: Formula to browse a specific folder, and return (display) the file with highest number

    Hi,
    After some testing, I came to the same conclusion.

    Thanks for the follow up!!!

+ 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