+ Reply to Thread
Results 1 to 2 of 2

VBA Macro to loop through folders and select files with certain criteria

  1. #1
    Registered User
    Join Date
    02-06-2014
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    1

    VBA Macro to loop through folders and select files with certain criteria

    I'm looking to create a macro that does the following:
    1. Loops through a folder structure
    2. Opens a specific subfolder within each folder based on name (i.e. "*Financials*")
    3. Opens a specific file within that subfolder "*Financials*" based on both most recently modified a naming criteria (i.e. "*Model*")
    4. Performs an action on that file (a macro created elsewhere that I assume I can call here)
    5. Closes that file, and moves on to the next file matching the criteria above

    As a self-diagnosed VBA novice, I'm having trouble adapting code found in various forums for my specific project.

    I've found examples that address aspects of my desired macro or do similar things, but I can't figure out how to put them together.

    Open most recent file:

    Please Login or Register  to view this content.
    Loop through folders and subfolders and print all files:
    Please Login or Register  to view this content.


    Any help is greatly appreciated.

  2. #2
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: VBA Macro to loop through folders and select files with certain criteria

    Would this get you up and running?
    Run the macro SearchThroughFolders() and enter the folder containing the subfolders you to search for the files you want to process.
    I marked the location where you could call your macro.

    BTW: if you need any additional help, please know that after next Sunday I will be away for the next 3 weeks and not able to answer your posts.
    Attached Files Attached Files
    Last edited by Tsjallie; 02-08-2014 at 05:23 PM.
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Renaming Folders in a macro but so far all I can do is loop thru the folder.
    By jody1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2013, 02:22 AM
  2. [SOLVED] Macro lists files in folders & subfldrs - Need to add ability for user to select folder
    By BeachBum08 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-31-2012, 12:15 PM
  3. Search Folders and Return Copy files matching multiple criteria
    By akq125 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2012, 11:56 PM
  4. Macro - Collect data - Select folder and loop through all xls files
    By zmalach in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2008, 10:37 AM
  5. Macro - Collect data - Select folder and loop through all xls files
    By kostas in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-04-2008, 05:58 AM

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