Sub ListFolders()
'''''''''''''''''''''''''''''''''''''''Makes List of Folders and Subfolders with paths for copying'''''''''''''''
Dim fs, f, f1, s, sf
Dim iRow As Long
Dim fd As FileDialog
Dim FolderName1 As String
ExtraSlash = "\"
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
.AllowMultiSelect = True
If .Show Then
For Each myFolder In .SelectedItems
FolderName1 = myFolder & ExtraSlash
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(FolderName1)
Set sf = f.SubFolders
Sheets("File List").Select
Range("A1").Select
For Each f1 In sf
ActiveCell.Value = f1.Name
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = f1.Path ''''''''''''''''''''''''''''''''''''''''''''''''
ActiveCell.Offset(0, -1).Activate
ActiveCell.Offset(1, 0).Activate
'iRow = iRow + 1
Next
Next
End If
End With
ListFiles FolderName1
End Sub
Sub ListFiles(FolderName1 As String)
'''''''''''''''''''''''''''''''''''''''Makes List of Folders and Subfolders with paths for copying'''''''''''''''
Dim fs As Object
Dim objFolder As Object
Dim objFile As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Set objFolder = fs.GetFolder(FolderName1)
Sheets("File List").Select '''change the name of the worksheet selected'''
Range("a1").Activate
r = Range("A1").CurrentRegion.Rows.Count
If r = 1 Then
For Each objFile In objFolder.Files
ActiveCell.Select
Selection.Formula = objFile.Name
ActiveCell.Offset(0, 1).Select
Selection.Formula = objFile.Path
ActiveCell.Offset(0, -1).Select
ActiveCell.Offset(1, 0).Select
Next
Else
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
For Each objFile In objFolder.Files
ActiveCell.Select
Selection.Formula = objFile.Name
ActiveCell.Offset(0, 1).Select
Selection.Formula = objFile.Path
ActiveCell.Offset(0, -1).Select
ActiveCell.Offset(1, 0).Select
Next
End If
Columns("A").Select
Selection.Columns.AutoFit
Range("A1").Select
''''''''''''''''''''''''''''''''''''''''''''''''
End Sub