+ Reply to Thread
Results 1 to 5 of 5

Find a folder by its name or wildcard (revisit)

  1. #1
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Find a folder by its name or wildcard (revisit)

    Hi all,

    Leith, had assisted in putting a function code together which searches a directory and
    and its sub directory for specified sub-directory for the given root path:
    L:\Global\Elec Dept Projects\

    With the use of a userforms combobox list of subfolders, I have the option to add a specific subfolder to the root path:

    L:\Global\Elec Dept Projects\Ready\
    Where (Ready) is a Status Folder which will holder a several job folders(aka 4WL - Project)

    If my filter includes a search word like : 4WL and I specify a subfolder (Ready), then the following function works like a charm.

    However, if a don't include a subfolder or allow my filter to be (*) then I run into problems.

    When I try to search by a folder name or partial name (*4WL*) just using the root path
    I will get an overstack error

    If I run using no filter word, just the (*) and the root, I get the root directory path returned along with the status folder paths, all listed mutiple times. No job folder paths will be returned.

    Please Login or Register  to view this content.
    I've been trying to figure out whats causing this issue for quite some time and still have yet to resolve this issue. If anyone, "Leith" or anyone else knows exactly whats causing this issue and can assist in resolving it, I'd be most grateful for the help.

    Source:
    http://www.excelforum.com/excel-prog...-wildcard.html

    Thanks,

    BDB
    Last edited by bdb1974; 09-07-2011 at 12:55 PM.

  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: Find a folder by its name or wildcard (revisit)

    Hello BDB,

    I hope you have this line uncommented:
    Please Login or Register  to view this content.

    This is an essential part of the macro. This is the global array that contains the folders.
    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
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Find a folder by its name or wildcard (revisit)

    Hi Leith,

    Thanks for replying,

    I do have Dim FolderList() As Variant uncommented.
    I think the problem is somewhat 2 fold.
    First, If I search with (*) and don't specify a subfolder, then it should return every
    job folder within each status folder. However, since it will only recursively check for
    a subfolder only if the filter string is found in the folder name. So, if a user puts in
    a partial job folder name (4wl*) then next level sub folders will not contain the filter therefore
    keeping it from searching the next sub folder level.

    Second, the stack space issue is being cause by the array becoming too large I think.


    Anyhow, after some thought, I really didn't understand why having an array was even needed when a folder path could be added directly to the listbox if the folder name matched the filter. So, I eliminated the use of the array and now it seems to run more
    efficiently without getting bogged down. I'm able to bring in every folder path if the input for the filter is left empty by searching only with (*) or do a selective search (*4wl*).
    I can narrow my search by adding a specific status folder to the root path, which speeds
    the search time. Using an imput for the filter is optional in both cases. And both cases are returing the all paths accordingly.

    I believe I now have this solved.

    Thanks again for your support,

    BDB

  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: Find a folder by its name or wildcard (revisit)

    Hello BDB,

    The stack space issue may be due to the depth of the files and folders you are searching through. The recursion process loads the stack with data until it reaches the end folder for a path before it starts removing data. Depending on what other processes your are running on your computer at the same time, this can use all the stack space you have available.

  5. #5
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Find a folder by its name or wildcard (revisit)

    Thanks Leith for the explanation.

    In any case it's now working

    BDB

+ 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