Option Explicit
Public Sub ProcessAllFiles()
'give the start folder
ScanFilesIn1Folder range("A1").value '"c:\temp\"
End Sub
Private Sub ScanFilesIn1Folder(ByVal pvStartDir)
Dim FileSystem As Object
Dim Folder As Object
Dim oFile As Object
Set FileSystem = CreateObject("Scripting.FileSystemObject")
Set Folder = FileSystem.GetFolder(pvStartDir)
For Each oFile In Folder.Files
'If InStr(oFile.Name, "backup") > 0 Then GoTo skip1
If InStr(oFile.Name, ".xls") > 0 Then 'only xl files
ProcessMyFile oFile
End If
skip1:
Next
Set oFile = Nothing
Set Folder = Nothing
Set FileSystem = Nothing
End Sub
Private Sub ProcessMyFile(ByVal poFile)
Workbooks.Open poFile
'do stuff here
ActiveWorkbook.Close True
End Sub