+ Reply to Thread
Results 1 to 4 of 4

Search for files, then return file path

  1. #1
    Registered User
    Join Date
    05-12-2009
    Location
    Udevalla, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    85

    Search for files, then return file path

    Hey guys.

    I was wondering if you could help me out here.
    I have a list of names and I want to search specific folders for any filenames that contains that name and then return the filepath to those files into Excel.

    The list of names I have look like this:

    07_0088
    08_0086
    20-07-00889-01
    etc..

    Then I have a cell which contains the filepath.
    Like:
    C:\My Documents\


    So what I want the macro to do is to search for all files in a given path where the filename
    contains *07_0088*. Then return the full filepath back into an Excel sheet.
    Something like:
    C:\My Documents\07_0088_CR.xls
    etc.

    I have made something like this before, but that macro only returns one file (the first one it finds). I want something that can look for multiple files and return all results.


    Any help will be MUCH appreciated
    Last edited by Carlsbergen; 05-11-2010 at 01:58 AM.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Search for files, then return file path

    See attached file, I hope it can help you.

    This is the macro, In range B2 put the path where to look for files and in range A5:An put files to search:
    Please Login or Register  to view this content.
    Regards,
    Antonio
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    05-12-2009
    Location
    Udevalla, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Search for files, then return file path

    Hi Antoka05

    The searching works, but it will only return the path of one file even though there are multiple files that match the search criteria.
    What I need is something that will return all the matches.

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

    Re: Search for files, then return file path

    Hello Carlsbergen,

    I have made a correction to Antonio's macro. This work now.
    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