The following code lists all the directories under c:\Temp
Function GetSubDir(ByVal sDir)
Dim oFS As New FileSystemObject
Dim oDir
Set oDir = oFS.GetFolder(sDir)
For Each oSub In oDir.SubFolders
MsgBox oSub.Path
GetSubDir oSub.Path
Next oSub
End Function
You can call the function like shown below
GetSubDir "C:\Temp\"
The code uses FileSystemObject from Microsoft Scripting RunTime. You need to add reference to this library (see figure below)
See also VBA Dir Function to Get Sub Directories