Consulting

Results 1 to 8 of 8

Thread: Retrieving all files in folder or subfolder containing specific text

  1. #1
    VBAX Newbie
    Joined
    Aug 2019
    Posts
    3
    Location

    Retrieving all files in folder or subfolder containing specific text

    Hi everyone, this is my first post here so please be patient with me.

    I am looking to create a macro that looks through all files in a folder and its subfolders (and potentially expand it later to look through the whole drive) that contain a specific ID (alpha-numeric with symbols, not sure if that makes a big difference). Ideally I would like to retrieve the files, but a list of the files that contain that text would be good too.

    I am not asking for the code to do it, I am learning how to use VBA and would like to do it myself to improve my learning process. I would really appreciate some guidance towards where to start and what resources that some of you know about (preferably free) that I can use to learn the tools and coding skills I can use to develop this and further my understanding of the process of creating complex macros.

    Any help or direction is very much appreciated!

    Thank you!

  2. #2
    Is this ID in the name of the file or in the content of the file?
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    VBAX Newbie
    Joined
    Aug 2019
    Posts
    3
    Location
    Thanks for the quick reply!

    In some it would be in both, but I would want to retrieve any file that contains that ID.

  4. #4
    If it's just in the name you can use Data, Get Data, From FIle, From Folder.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  5. #5
    VBAX Newbie
    Joined
    Aug 2019
    Posts
    3
    Location
    Sorry for the late reply!

    Well the idea is that I'd like it to open the files that contain that ID or provide me with a list whenever I enter in a different ID if that makes sense. I'd want to search for an ID and open or provide a list of all the files that contain that ID.

    For example: I'd type in 1A-2B-C3 and have it retrieve all files that contain that ID, then do the same for another ID like 2A-1B-C3 and so on.

  6. #6
    That would be a very slow process as each file would have to be opened. One way to do this is by using file indexing and searching software. LIke the ones discussed here: https://www.lifewire.com/11-free-fil...-tools-1356644
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  7. #7
    VBAX Regular
    Joined
    Aug 2019
    Posts
    8
    Location
    I know this is potentially not what you're looking for, but if I'm understanding correctly, you could use Power Query to achieve this.
    This would work well assuming the files are in the same/similar format. It largely depends on what you're end goal is.

    I won't go into anymore detail yet because it is probably not what you're looking for but let me know if you want to explore this further.

  8. #8
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    Windows has that searching option built-in.
    VBA can't add anything to that option.

    To learn VBA you should start simply, using the library of a specific Office Program: Excel, Word, Powerpoint, Access, Outlook

Posting Permissions

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