> You can get a quick list of the files in a folder with this macro. Put
> the folder path in cell A1.
[quoted text clipped - 32 lines]
>> I do not understood the rest of your instructions. Could you please
>> clarify?
Here's two ways to drill into subfolders:
1. Requires a reference to MS Scriptiong Runtime:
Option Compare Text
Sub ListXLFiles()
Dim FilesCollection As New Collection, Counter As Long
FindFiles "c:\excel", "*.xls", FilesCollection, True
Sheet1.Columns(1).Clear
For Counter = 1 To FilesCollection.Count
Sheet1.Cells(Counter, 1).Value = FilesCollection(Counter)
Next
End Sub
Sub FindFiles(FolderName As String, FileSpec As String, Col As Collection,
Recurs As Boolean)
Dim fso As Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim fldSub As Scripting.Folder
Dim fle As Scripting.file
Set fso = New Scripting.FileSystemObject
Set fld = fso.GetFolder(FolderName)
For Each fle In fld.Files
If fle.Name Like FileSpec Then Col.Add fle.Path
Next
If Recurs Then
For Each fldSub In fld.SubFolders
FindFiles fldSub.Path, FileSpec, Col, True
Next
End If
Set fso = Nothing
End Sub
2. Uses FileSearch which I believe is not in Excel 2007.
Sub FileSearchList()
Dim i As Integer
Sheet1.Columns(2).Clear
With Application.FileSearch
.NewSearch
.LookIn = "c:\excel"
.SearchSubFolders = True
.Filename = "*.xls"
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Sheet1.Cells(i, 2).Value = .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub

Signature
Jim
> Jim,
>
[quoted text clipped - 39 lines]
>>> I do not understood the rest of your instructions. Could you please
>>> clarify?
RobN - 19 May 2007 05:16 GMT
Thanks Jim,
Very helpful!
Rob
> Here's two ways to drill into subfolders:
>
[quoted text clipped - 95 lines]
>>>> I do not understood the rest of your instructions. Could you please
>>>> clarify?