+ Reply to Thread
Results 1 to 2 of 2

Search for files in directory and subdirectories using wildcard

Hybrid View

modytrane Search for files in directory... 05-23-2013, 09:58 AM
AlvaroSiza Re: Search for files in... 05-23-2013, 10:13 AM
  1. #1
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Search for files in directory and subdirectories using wildcard

    Hi,
    I need to look for all files that contain a text string "tip" in their names. Once I find those files, I would open them and copy a worksheet "Input" in to my workbook.
    These files are located at different levels within a Directory / Sub directory structure.
    The root directory is W:\Projects\.
    Then under that there are various Project Folders and Sub Folders. The Files with "tip" string could be under any of those subdirectories.

    Can some one point in the right direction or maybe there is a routine available for this type of search?
    This search would be similar to the one that Windows Explorer has that will list all paths for these files.

    Thanks in advance for any help or guidance on this.

    modytrane.

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Search for files in directory and subdirectories using wildcard

    Morning Mody,

    I think you can likely alter the method presented here. I would also encourage you to visit the same website section regarding "ADO". While you will not be using ADO, the example workbook (with code) that you can download - Example 7 - deals specifically with the optional 'include subfolders' argument. You will need to blend the two and likely add snippets from elsewhere, but it can be done. Good luck.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

+ 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