Sub StartListing()
Dim TopFolderName As String
Dim TopFolderObj
Dim DestinationRange As Range
Set FSO = CreateObject("Scripting.FileSystemObject")
TopFolderName = "D:\DATA" '<<< CHANGE TO YOUR FOLDER
Set DestinationRange = Worksheets(1).Range("A1")
Set TopFolderObj = FSO.GetFolder(TopFolderName)
ListSubFolders OfFolder:=TopFolderObj, DestinationRange:=DestinationRange
End Sub
Sub ListSubFolders(OfFolder As Variant, DestinationRange As Range)
Dim SubFolder
DestinationRange.Value = OfFolder.Path
Set DestinationRange = DestinationRange.Offset(1, 1)
For Each SubFolder In OfFolder.SubFolders
ListSubFolders OfFolder:=SubFolder, _
DestinationRange:=DestinationRange
Next SubFolder
Set DestinationRange = DestinationRange(1, 0)
End Sub
Bookmarks