I found my mistake
Sub Auto_Open()
Dim objFSO As Object, objFolder As Object, objFile As Object
Dim i As Integer, ws As Worksheet, wt As Worksheet, R As Range
MyPath = ActiveWorkbook.Path
MyName = ActiveWorkbook.Name: Set ws = Sheets("Summary")
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder(MyPath)
Count = 0
Sheets("Summary").Select
For Each objFile In objFolder.Files
If objFile.Name <> MyName Then
Temp = objFile.Name
If objFile.Name Like "*.xls*" Then
MyLR = ws.Range("B" & Rows.Count).End(xlUp).Row
ChDir MyPath
On Error GoTo ExitSub
Application.DisplayAlerts = False
Workbooks.Open Filename:=Temp: Set wt = ActiveSheet
i = 1: Do Until Trim(wt.Cells(1, i)) = "RESERVE": i = i + 1: Loop
Set R = wt.UsedRange: R.AutoFilter Field:=i, Criteria1:=">0"
If MyLR > 2 Then MyLR = MyLR + 1
wt.UsedRange.SpecialCells(xlCellTypeVisible).Copy ws.Range("B" & MyLR)
i = MyLR: Do Until ws.Cells(i + 1, 2) = "": i = i + 1: Loop
ws.Range("A" & MyLR).Resize(i - MyLR + 1, 1).Value = wt.Parent.Name
If MyLR > 2 Then ws.Rows(MyLR).Delete Shift:=xlUp
wt.AutoFilterMode = False
Windows(objFile.Name).Close False
End If: End If
Next objFile
ExitSub: ws.Cells(1, 1) = "File Name": Application.DisplayAlerts = True: End Sub
Bookmarks