|
▼ESMEY さん:
これが使えます。いま小生が使っているコードです。
アレンジしてください。
Sub test3()
'Application.ScreenUpdating = False
Dim BK(1 To 5) As Workbook
Dim i As Integer
Set BK(1) = Workbooks.Open(ThisWorkbook.Path & "\Book1.xls")
Set BK(2) = Workbooks.Open(ThisWorkbook.Path & "\Book2.xls")
Set BK(3) = Workbooks.Open(ThisWorkbook.Path & "\Book3.xls")
Set BK(4) = Workbooks.Open(ThisWorkbook.Path & "\Book4.xls")
Set BK(5) = Workbooks.Open(ThisWorkbook.Path & "\Book5.xls")
For i = 1 To UBound(BK, 1)
With ThisWorkbook.Sheets(1)
.Range(.Cells(5, i + 1), .Cells(24, i + 1)).Value = _
BK(i).Sheets(1). _
Range(BK(i).Sheets(1).Cells(2, i), BK(i).Sheets(1).Cells(21, i)).Value
Next i
For i = 1 To 5
BK(i).Close False: Set BK(i) = Nothing Next i
'Application.ScreenUpdating = True
End Sub
|
|