+ Reply to Thread
Results 1 to 6 of 6

Set multiple strRoot paths under one strRoot

  1. #1
    Registered User
    Join Date
    05-19-2021
    Location
    Netherlands
    MS-Off Ver
    Version 2104
    Posts
    33

    Question Set multiple strRoot paths under one strRoot

    Currently I am using the following VBA code in Excel.

    When executed the code searches the cell's value on strRoot = "V:\" and opens the folder if the result is found.

    Please Login or Register  to view this content.
    Is it possible to set strRoot to a few semi fixed paths instead of the complete V:\ drive and all its subfolders?

    E.g. only search the following paths:

    V:\FOLDER 1\Subfolder 1\ (This path 2 folders deep)
    V:\FOLDER 2\ (This path 1 folder deep)
    V:\FOLDER 3\Subfolder 1\Subfolder 2 (This path 3 folders deep)

    I don't want the VBA to search a 1000+ files and folders but only search in these selected paths.

  2. #2
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,220

    Re: Set multiple strRoot paths under one strRoot

    Try:
    Please Login or Register  to view this content.
    Artik

  3. #3
    Registered User
    Join Date
    05-19-2021
    Location
    Netherlands
    MS-Off Ver
    Version 2104
    Posts
    33

    Re: Set multiple strRoot paths under one strRoot

    Much appreciated, but I dont think it does what I want. I tried the code but it still searches all Subfolders in a linear way.

    V:\FOLDER 1\Subfolder 1\Subfolder 2\Subfolder3\Subfolder4
    V:\FOLDER 2\Subfolder 1\Subfolder 2\Subfolder3\
    V:\FOLDER 3\Subfolder 1\Subfolder 2\Subfolder3\Subfolder4\Subfolder5

    Example: If my StringID (the value which is used to search for my folder) is inside V:\FOLDER 2\Subfolder 1 the command still searches in a linear way through all Subfolders under FOLDER 1 (so Subfolder 1 to 4) before searching the Subfolders under FOLDER 2. What I want is the search doesnt go beyong Subfolder 2 under FOLDER 1 (see depth in RED).

    Is there another way to do this, or set lMaxLevel = 2 'Maximum depth of subfolders per folder under my V:\ drive

  4. #4
    Registered User
    Join Date
    05-19-2021
    Location
    Netherlands
    MS-Off Ver
    Version 2104
    Posts
    33

    Re: Set multiple strRoot paths under one strRoot

    I've done some extensive testing and searching online for solutions but I still haven't been able to figure the above out.
    Anyone else who could assist me in my issue or send me in the right direction?

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Set multiple strRoot paths under one strRoot


    Hi,

    as you can use only the Dir VBA function for each folder path …
    Last edited by Marc L; 02-21-2022 at 12:02 PM.

  6. #6
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Set multiple strRoot paths under one strRoot

    Quote Originally Posted by Nebucanezars View Post
    ... who could ... send me in the right direction?
    Use maybe "FileDialog" to dictate/force the choice of a particular directory nesting, e.g.:
    Please Login or Register  to view this content.

+ 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. How to copy multiple image file paths from different folders in the go
    By AndyEastop in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 05-05-2021, 11:30 AM
  2. Looking to incorporate multiple file paths into a lookup formula
    By BaronVonTeabag in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-19-2020, 10:42 AM
  3. [SOLVED] Save Master Workbook multiple filenames and paths based on column values
    By kermit_d_frog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-28-2019, 02:02 PM
  4. Insert multiple pictures using VBA referencing file paths
    By Nickmac1212 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-01-2016, 01:27 PM
  5. Paste multiple folder/file paths into excel using VBA
    By sherlucky in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-24-2016, 05:01 PM
  6. VBA code to get list of files from multiple paths
    By sn152 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2015, 08:09 AM
  7. [SOLVED] Complex IF Statement Not Recognizing Multiple Paths
    By EnigmaMatter in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-12-2014, 02:14 PM

Tags for this Thread

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