+ Reply to Thread
Results 1 to 7 of 7

Where found in multiple folders

  1. #1
    Registered User
    Join Date
    10-19-2011
    Location
    Barkhamsted, CT
    MS-Off Ver
    Excel 2013
    Posts
    22

    Question Where found in multiple folders

    Good afternoon everyone,
    In a cell I have a text string...C00023. I would like to have some VBA code or other way which will take that string and search in a specific folder which contains sub-folders and return a list of all the excel files which contain that string. I can do a search with the microsoft search engine to obtain the list, so if it that can be set up to run with code, that should be good. I have searched forums and googled but trying to phrase the question clutters the results.

    Any help would be appreciated.

    Ken

  2. #2
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Where found in multiple folders

    http://lmgtfy.com/?q=Excel+2010+VBA+...and+Subfolders

    http://www.ozgrid.com/forum/showthre...t=69086&page=1
    Last edited by Whizbang; 10-19-2011 at 02:50 PM.

  3. #3
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Where found in multiple folders

    You need to change strPath to the directory you are searching through. The code compares the file names there to the string in cells(1,1), which is A1 on the active sheet. The results are returned in column B.

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  4. #4
    Registered User
    Join Date
    10-19-2011
    Location
    Barkhamsted, CT
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Where found in multiple folders

    Thanks for the reponses. But it does not seem either helped Dave, yours looked promising. I placed the code in the ThisWorkbook and a seperate module. I placed a folder in my directory called C00023 and it did not work. I actually would like it to list the Excel files which have the text string C00023 located somewhere in the file.
    To give a better idea C00023 is our internal part number for a capacitor. I have a folder which contains individual Bill of Material Excel files for our different products. Some of which are in sub-folder. I would like to type C00023 in cell A1 and have it search and list all the files which contain that text in cell B1.
    Thank you for the help.
    Ken

  5. #5
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Where found in multiple folders

    Did you change the definition of strPath as I instructed?
    How is it not working? If there is an error, which line?

  6. #6
    Registered User
    Join Date
    10-19-2011
    Location
    Barkhamsted, CT
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Where found in multiple folders

    I did change the path. Does it make a difference if it is on a network drive and not my computer? Sorry that may have been important. With the VBA box open I selected the code and hit run and nothing happens.

  7. #7
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Where found in multiple folders

    Ah, I see. He wants to do a text search within the file itself, not just the filename.

    For that you would need to open each file, search it, then close and move on. Maybe there is an API or two that can be used to mimic the File Search done at the Windows level. I don't know.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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