|
Sub open_file()
Dim fso, folder1, files As Object
Dim wb As Workbook
Set fso = CreateObject("scripting.filesystemobject")
folderpath = ThisWorkbook.Path
MsgBox folderpath
Set folder1 = fso.getfolder(folderpath)
Set files = folder1.files
For Each file In files
If Split(file.Name, ".")(0) <> Split(ThisWorkbook.Name, ".")(0) And Split(file.Name, ".")(1) <> "xlsm" Then
Set wb = Workbooks.Open(folderpath & "/" & file.Name)
irow = ThisWorkbook.Sheets(1).Range("a65536").End(3).Row + 1
With ThisWorkbook.Sheets(1)
.Cells(irow, 1).Value = Split(wb.Sheets(1).Cells(2, 7), ":")(1)
.Cells(irow, 2).Value = wb.Sheets(1).Cells(4, 1)
.Cells(irow, 3).Value = wb.Sheets(1).Cells(4, 4)
.Cells(irow, 4).Value = wb.Sheets(1).Cells(4, 5)
.Cells(irow, 5).Value = wb.Sheets(1).Cells(4, 6)
.Cells(irow, 6).Value = wb.Sheets(1).Cells(4, 7)
.Cells(irow, 7).Value = wb.Sheets(1).Cells(4, 8)
.Cells(irow, 8).Value = wb.Sheets(1).Cells(6, 1)
.Cells(irow, 9).Value = wb.Sheets(1).Cells(6, 4)
.Cells(irow, 10).Value = wb.Sheets(1).Cells(6, 6)
.Cells(irow, 11).Value = wb.Sheets(1).Cells(6, 7)
.Cells(irow, 12).Value = wb.Sheets(1).Cells(6, 8)
.Cells(irow, 13).Value = wb.Sheets(1).Cells(8, 2)
.Cells(irow, 14).Value = wb.Sheets(1).Cells(8, 4)
.Cells(irow, 15).Value = wb.Sheets(1).Cells(8, 5)
.Cells(irow, 16).Value = wb.Sheets(1).Cells(8, 7)
.Cells(irow, 17).Value = wb.Sheets(1).Cells(8, 8)
.Cells(irow, 18).Value = wb.Sheets(1).Cells(9, 2)
.Cells(irow, 19).Value = wb.Sheets(1).Cells(9, 4)
.Cells(irow, 20).Value = wb.Sheets(1).Cells(9, 5)
.Cells(irow, 21).Value = wb.Sheets(1).Cells(9, 7)
.Cells(irow, 22).Value = wb.Sheets(1).Cells(9, 8)
.Cells(irow, 23).Value = wb.Sheets(1).Cells(10, 2)
.Cells(irow, 24).Value = wb.Sheets(1).Cells(10, 4)
.Cells(irow, 25).Value = wb.Sheets(1).Cells(10, 5)
.Cells(irow, 26).Value = wb.Sheets(1).Cells(10, 7)
.Cells(irow, 27).Value = wb.Sheets(1).Cells(10, 8)
wb.Close
End With
End If
Next
End Sub
|
|