You'll need to Dim SubDirName as a variant for this to work
Declare a Collection variable Dim SubDirNames As Collection
Modify this code as needed to add the SubDirName(s) to the Collection SubDirNames
' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.'
MyName = Dir(MyPath, vbDirectory)
' Retrieve the first entry.
Do While MyName <> ""
' Start the loop. ' Ignore the current directory and the encompassing directory.
If MyName <> "." And MyName <> ".." Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Debug.Print MyName '''''''''''''''''''''''''''''''''''''''''''''''''''''''' SubDirNames. Add SubDirName
End If ' it represents a directory.
End If
MyName = Dir
' Get next entry.
Loop
Then loop thru the SubDirNames collection with
For Each SubDirName in SubdirNames
in the code you already have.
If you have more than 1 subfolder deep, then you are out of my league. It would take me all night to figure that one out.
Why don't you take all night, then we here at VBAX can go over what you have.