What an excellent resource of a site. I have a multiple part question I could definitely use some assistance on. I am using a simple recursive folder listing macro that I would like to execute multiple times by changing the folder location in the macro. I haven't quite figured out how to do this, which leads me to here.
Here's the code I would like to manipulate:
I can get this to run as multiple macros on different sheets by changing the Sub name, Sheet number and Folder location. However I would like this to look in 6 different locations and compile a single list, by using the next free cell after the first part of the macro is done. Any input on this would be great.![]()
Sub ListFiles1() Dim startRange As Range Set startRange = Sheet1.Range("A1") 'Parent Directory - Change this to whichever directory you want to use ListFoldersAndInfo "Z:\TestList1", startRange, 0 End Sub Sub ListFoldersAndInfo(foldername As String, Destination As Range, Level As Long) Dim FSO As Object Dim Folder As Object Dim R As Long Dim SubFolder As Object Dim Wks As Worksheet Set FSO = CreateObject("Scripting.FileSystemObject") Set Folder = FSO.GetFolder(foldername) Destination = Folder.Name Destination.IndentLevel = Level Destination.Offset(0, 1) = Folder.Size Set Destination = Destination.Offset(1, 0) For Each SubFolder In Folder.SubFolders ListFoldersAndInfo Folder.Path & "\" & SubFolder.Name, Destination, Level + 1 Next SubFolder Set FSO = Nothing End Sub
Thanks.
Bookmarks