'https://www.excel-downloads.com/threads/vba-liste-dossiers-et-sous-dossiers-dun-dosssier.126930/page-2#posts
Dim ligne
Sub arborescenceRepertoire()
racine = ChoixDossier() ' ou un répertoire C:\xxx e.g.
If racine = "" Then Exit Sub
Range("A:h").ClearContents
Set fs = CreateObject("Scripting.FileSystemObject")
Set dossier_racine = fs.getfolder(racine)
ligne = 3
Lit_dossier dossier_racine, 1
'*** Cells(3, 2) = fs.getfolder(racine).Size
End Sub
Sub Lit_dossier(ByRef dossier, ByVal niveau)
Cells(ligne, niveau) = dossier.Name
'*** Cells(ligne, niveau + 1) = dossier.Size
ligne = ligne + 1
For Each d In dossier.SubFolders
Lit_dossier d, niveau + 1
' MsgBox niveau
Next
End Sub
Function ChoixDossier()
If Val(Application.Version) >= 10 Then
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = ActiveWorkbook.Path & "\"
.Show
If .SelectedItems.Count > 0 Then
ChoixDossier = .SelectedItems(1)
Else
ChoixDossier = ""
End If
End With
Else
ChoixDossier = InputBox("Répertoire?")
End If
End Function