+ Reply to Thread
Results 1 to 4 of 4

How to modify current looping directory program to include subfolders

  1. #1
    Registered User
    Join Date
    04-02-2010
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    22

    How to modify current looping directory program to include subfolders

    I am trying to loop through a directory, "U:\bsides\Quotes\BUYERS GUIDE\", and as it stands, I have to specify the subfolder and since there are 5 that contain "*.xlsx" file extensions, I have to this long list of code, 5X as long as it needs to be, referencing each different subfolder as the path. I have essentially just copy and pasted the same code 5 times, changing the path for each. In the future, there may be more than 5 subfolders, so I was wondering what do I need to add to include the search of subfolders.

    Here is the code:
    Please Login or Register  to view this content.
    This works fine for now, just if I add subfolders, I have to copy and paste more code, and I figured there is probably an easier way to do this.

  2. #2
    Registered User
    Join Date
    04-02-2010
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: How to modify current looping directory program to include subfolders

    Just as reference, that "bunch of random formatting and search code" is over 200 lines each.

  3. #3
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: How to modify current looping directory program to include subfolders

    hi,

    I haven't gone through your code but I have working code that loops through sub-folders. I use occasionally & it works well for me so hopefully you can modify it to incorporate your formatting code (instead of it creating a list of files on a new sheet). Here it is - unmodified, so you'll need to modify the "guts" of the GetFiles macro...

    Please Login or Register  to view this content.
    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  4. #4
    Registered User
    Join Date
    04-02-2010
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: How to modify current looping directory program to include subfolders

    Thanks, I quickly glanced through it. I might try to incorporate a few lines here and there for code. I will tinker with it tomorrow at work.

+ 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