The best way to do this is to create a collection
Fill it with the directories
Loop through that collection and only get the sub directories for the ones beggining with "Site"
Then outoput the collection.
there are many different folder structure so your best bet is to tailor the sample code below.
Dim Dirs As New Collection
Dim strPath As String
Dim strFile As String
Dim x As Integer
strPath = "Z:\Projects\"
strFile = Dir(strPath, vbDirectory)
Do While Len(strFile)
If strFile <> "." And strFile <> ".." Then
Dirs.Add strFile
End If
strFile = Dir
Loop
For x = 1 To Dirs.Count
strFile = Dir(strPath & Dirs.Item(x) & "\", vbDirectory)
Debug.Print Dirs.Item(x) & " : " & strFile
Do While Len(strFile)
If strFile <> "." And strFile <> ".." And InStr(1, strFile, "Site") > 0 Then
Dirs.Add strFile
End If
strFile = Dir
Loop
Next
For x = 1 To Dirs.Count
Debug.Print Dirs.Item(x)
Next
Enter your message below
Sign in or Join us (it's free).