+ Reply to Thread
Results 1 to 6 of 6

VBA to: Look in folder for .xlsm file, and list its filename in cell

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

    VBA to: Look in folder for .xlsm file, and list its filename in cell

    Hi,
    I'm looking for VBA code that will look in a specific folder (fixed filepath) for a .xlsm file (there will only be one .xlsm file in the folder). I would then like to have the filename of that single .xlsm file displayed in cell A1.

    How do I write a macro to:

    Look in:
    C:\Test\Test_Folder
    Find:
    ".xlsm" (unknown filename)
    Range("A1"). Value= (unknown filename)

    Thanks for the help!!!

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: VBA to: Look in folder for .xlsm file, and list its filename in cell

    Hi,
    Will there only be one .xlsm file in the folder?

  3. #3
    Forum Contributor
    Join Date
    01-03-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: VBA to: Look in folder for .xlsm file, and list its filename in cell

    In this case (fixed filepath, one xlsm file) I think you can try something like this:
    Please Login or Register  to view this content.

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

    Re: VBA to: Look in folder for .xlsm file, and list its filename in cell

    Thanks for the replies so far, I'll try that code when I get home.

    Yes, I foresee only one .xlsm file in the folder at any given time.

    Otherwise, what would have to be included to accommodate, say 5 total files in the folder?

    If that overly complicates things, forget about it.

    A1 = file1
    A2 = file2
    A3 = file3
    Etc...

    Tha

  5. #5
    Forum Contributor
    Join Date
    01-03-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: VBA to: Look in folder for .xlsm file, and list its filename in cell

    Try this, should look for every xlsm file in a given folder:


    Please Login or Register  to view this content.

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

    Re: VBA to: Look in folder for .xlsm file, and list its filename in cell

    Sbarro, I am quite thankful for your assistance. Both versions work perfectly, and are efficiently done; nice job!

    I have some other code that I'm going add in, so it should be a nifty deal.

    Thanks again!

+ 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