This will work: it puts the files in Column A,
starting with A1. It should be fairly clear
how to modify it to meet your needs.
Sub trythis()
Dim Path As String
Range("A1:A65000").ClearContents
Path = InputBox(prompt:="Enter the path of the folder to search:", Title:="Mrexcel.com")
With Application.FileSearch
.NewSearch
.LookIn = Path
.SearchSubFolders = True ' change as needed
.FileName = "*" ' Change as needed
.MatchAllWordForms = True
.FileType = msoFileTypeAllFiles ' change as needed
If .Execute(SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
Cells(i, 1) = .FoundFiles(i) ' results in cell A[1-n]
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub
Good luck!
Thanks Tim,
I knew there would be some clever person out there who'd know.
Thanks again,
Rhona.