+ Reply to Thread
Results 1 to 4 of 4

Searching for folders

  1. #1
    Registered User
    Join Date
    04-20-2010
    Location
    Holland
    MS-Off Ver
    Excel 2007
    Posts
    11

    Searching for folders

    I have a lot of nested folder which needs to be sorted out.
    It would be a lot easier if I would have some code which would go trough all my folders and makes a list of each folder which has a subfolder called Mapping.

    For example search trough all folders in C:\Temp

    C:\Temp\folder x\ other folder\Mapping would return C:\Temp\folder x\ other folder
    C:\Temp\folder x\ other folder\folder y\ would return nothing as there is no folder called mapping

    but if there is then inside:
    C:\Temp\folder x\ other folder\folder y\folder z\Mapping it would return C:\Temp\folder x\ other folder\folder y\folder z\

    Hope you understand and can help me. I have no idea where to start with this. Couldn't find any help so far on the internet.
    Last edited by Tjeu; 04-23-2010 at 09:52 AM. Reason: solved

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Searching for folders

    Hello Tjeu,

    Not sure if this what you are looking for, but it should be a good start. This macro will create an array of all folders and subfolders for a given directory. There is another macro to list the array on the active worksheet in column "A".
    Please Login or Register  to view this content.


    List Folders on the Active Sheet
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-06-2010
    Location
    Wellington, New Zealand
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Searching for folders

    Nice use of recursion there Leith, very elegant. I was having trouble a while ago with the SubFolders as it only returns the immediate subfolders not all nested subfolders (as you would think). Nice solution.

    regards,
    Graham

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Searching for folders

    Hello parrynz,

    Thank you glad it helped.

+ 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