Excel VBA Learn how to loop through folders and subfolders
The code used in this video:
Sub SetFolders()
Dim path As String
Dim folder As String
Dim row As Integer
path = "C:\Weekly Reports\"
folder = Dir(path, vbDirectory)
row = 1
Do While folder ""
If folder "." And folder ".." Then
If (GetAttr(path & folder) And vbDirectory) = vbDirectory Then
Cells(row, 1) = path & folder
row = row + 1
End If
End If
folder = Dir()
Loop
End Sub
Ещё видео!