+ Reply to Thread
Results 1 to 7 of 7

Looping through Subfolders within a Parent Folder

  1. #1
    Registered User
    Join Date
    05-30-2013
    Location
    Connecticut
    MS-Off Ver
    Excel 2010
    Posts
    80

    Looping through Subfolders within a Parent Folder

    I have a macro that is designated to run on workbooks within a subfolder but in order to run it I need to first be able to have the Macro open a parent folder, then open each sub folder individually-- at which point my Macro can be run. The parent folder is called lots and the sub folders are all named as a series of digits. The Macro that I want to run creates a report based on data within the sub folders. I was thinking of having the user save the report in the lots folder in order to get the users file path and then using that file path to tell the computer where to begin looping through subfolders.

    I am still new to VBA and having trouble with loops, any help would be appreciated, thanks.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Looping through Subfolders within a Parent Folder

    why not paste here please your code ?
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    05-30-2013
    Location
    Connecticut
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Looping through Subfolders within a Parent Folder

    This Macro is only capable of being executed once the user has saved the report within the subfolder. I need something to first open the subfolder
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Looping through Subfolders within a Parent Folder

    Quote Originally Posted by bocaj315 View Post
    This Macro is only capable of being executed once the user has saved the report within the subfolder. I need something to first open the subfolder
    Do you mean CREATE subfolder ?

  5. #5
    Registered User
    Join Date
    05-30-2013
    Location
    Connecticut
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Looping through Subfolders within a Parent Folder

    No, the subfolder already exists. Like I said the parent folder is called lots and the subfolders are all named by a series of digits. Ex. 130050. I need the macro to be able open 130050 and then run what I already have

  6. #6
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Looping through Subfolders within a Parent Folder

    If you need only one subfolders level you can arrange this code
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-30-2013
    Location
    Connecticut
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: Looping through Subfolders within a Parent Folder

    Thank you very much. Would you also be able to assist me in determining where to place this piece of code?

+ 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] list of subfolders in folder - without files and sub-subfolders
    By MartyZ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2022, 10:56 AM
  2. Counting files in folder including subfolders also and folder size
    By mido609 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 03:26 PM
  3. Help w/making this list Parent directory,Subfolders,and files
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-16-2008, 07:09 PM
  4. Replies: 2
    Last Post: 05-07-2006, 03:20 PM
  5. get the parent folder of the working folder
    By tom taol in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-15-2005, 12:05 PM

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