Dim Files As Collection
Set Files = GetFilesIn("C:\") 'gets all the files
Set Files = GetFilesIn("C:\", "*.txt") 'gets all the txt files
Set Files = GetFilesIn("C:\", , "*.txt") 'gets all but the txt files
Function GetFilesIn(Folder As String, Optional Matching As String, Optional Unmatching As String) As Collection
Dim FName As String
Set GetFilesIn = New Collection
If Matching = "" Then
FName = Dir(Folder)
Else
FName = Dir(Folder & Matching)
End If
Do While FName <> ""
If Unmatching = "" Then
GetFilesIn.Add Folder & FName
Else
If Not FName Like Unmatching Then GetFilesIn.Add Folder & FName
End If
FName = Dir
Loop
End Function