|
PIさん、Keinさん
こんばんは、横レス失礼します。
基本はPIさんのコードをそのまま使って、こんな感じでどうですか?
Dim Book(1 To 5) As Workbook
Dim i As Integer
On Error Resume Next
Set Book(1) = Workbooks.Open(ThisWorkbook.Path & "\A111.xls")
Set Book(2) = Workbooks.Open(ThisWorkbook.Path & "\A222.xls")
Set Book(3) = Workbooks.Open(ThisWorkbook.Path & "\A333.xls")
Set Book(4) = Workbooks.Open(ThisWorkbook.Path & "\A444.xls")
Set Book(5) = Workbooks.Open(ThisWorkbook.Path & "\A555.xls")
For i = 1 To UBound(Book, 1)
With ThisWorkbook.Sheets(1)
.Range(.Cells(i + 5, 2), .Cells(i + 5, 3)).Value = _
Book(i).Sheets(1).Range("A1:B1").Value
.Range(.Cells(i + 4, 4), .Cells(i + 4, 5)).Value = _
Book(i).Sheets(2).Range("A1:B1").Value
End With
Next i
For i = 1 To 5
Book(i).Close False: Set Book(i) = Nothing
Next i
On Error GoTo 0
|
|