+ Reply to Thread
Results 1 to 7 of 7

loop through files in a folder based on partial name from worksheet cell

  1. #1
    Forum Contributor
    Join Date
    09-19-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    137

    loop through files in a folder based on partial name from worksheet cell

    I need a macro to open all files in a folder that have the value in a cell somewhere in their filename. The files will be opened and closed one by one to copy some info and paste into the active workbook. Here's something to give you an idea what I'm after:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: loop through files in a folder based on partial name from worksheet cell

    You could try something like:
    Please Login or Register  to view this content.
    Last edited by ragulduy; 07-02-2013 at 10:18 AM.

  3. #3
    Forum Contributor
    Join Date
    09-19-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    137

    Re: loop through files in a folder based on partial name from worksheet cell

    Thanks yudlugar, do I need to set 'fil' to anything?

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: loop through files in a folder based on partial name from worksheet cell

    It should assign it to the files in the folder (the line 'for each fil in fol.files' does this) and loop through them. You do not need to define it outside of the loop.

  5. #5
    Forum Contributor
    Join Date
    09-19-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    137

    Re: loop through files in a folder based on partial name from worksheet cell

    Hmm, i can tell it's close but it actually doesn't open anything, and then it closes the "console" workbook.

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: loop through files in a folder based on partial name from worksheet cell

    How about:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    09-19-2012
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    137

    Re: loop through files in a folder based on partial name from worksheet cell

    Thanks yudlugar! the first one actually worked, I just had to adjust my 'criteria' values.

    Best regards,

    Willardio

+ 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