Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    Oct 2015
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile Search file content for a specific string contained in cell and return the file path in next column.

    Dear All,

    I have a large number of strings in column a in Excel, so I need to search the cell values inside text, .doc etc. files and return the file path in column B (if there are more files, post them in the next column)

    I have searched the web and found on this thread http://windowssecrets.com/forums/sho...urn-path/page2, but it searches the file name, I need the file content.

    Thanks in advance.

  2. #2
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,829
    Thanks
    136
    Thanked 483 Times in 460 Posts
    Hi

    ..it would help to have bit more info about what you are trying to do, perhaps with some examples??

    zeddy

  3. #3
    New Lounger
    Join Date
    Oct 2015
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hello,

    Thanks for the reply, So I have a number of strings in Column A, I need to search the A cells value inside a directory containing text files, those text files contain the Value from column A , after the search was done, in column B (or if there are more matches in next column) excel will return the file name containing the string from Column A.

    Thanks!
    Attached Files Attached Files

  4. #4
    Lounger
    Join Date
    Feb 2011
    Posts
    28
    Thanks
    0
    Thanked 10 Times in 8 Posts
    Hi, I think the attached does what you require - with a little help from Hans Vogelaar!
    Attached Files Attached Files

  5. #5
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,829
    Thanks
    136
    Thanked 483 Times in 460 Posts
    Hi Stefan

    ..my approach would be to search a specified folder for files that match a chosen file-pattern (e.g *.txt, *.doc, *.prn etc etc).
    Then, instead of opening each relevant file multiple times, just open it once to test if it contains any of the text strings listed in column [A].
    I'm looking at a more efficient way of doing this, that doesn't require opening the relevant text files.
    Are you searching just *.txt files???
    What about word doc files????
    Can we ignore large files (e.g only search in txt files <100KB etc etc)

    zeddy

  6. #6
    New Lounger
    Join Date
    Oct 2015
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you for the reply Zeddy,

    There should be more types of files, doc. prn etc.
    I think you can ignore Large files...
    Thank you!

  7. #7
    Lounger
    Join Date
    Feb 2011
    Posts
    28
    Thanks
    0
    Thanked 10 Times in 8 Posts
    I look forward to seeing your alternate approach zeddy!

    In the meantime, I've altered my code so that each file is opened only once so it'll be quicker, but this will probably only work with text/prn files but not .doc files - apologies for not reading the initial question fully... Hopefully someone will it useful.
    Attached Files Attached Files

  8. The Following User Says Thank You to unclehewie For This Useful Post:

    munteanstefan (2015-10-28)

  9. #8
    New Lounger
    Join Date
    Oct 2015
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you unclehewie, this worked out for me perfectly!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •