|
▼kanabun さん:
このようにしたら出来たみたいです。
ありがとうございました。
Sub Test()
Dim Files, FilesCnt As Integer, i As Integer
Dim cBook As Workbook, pBook As Workbook
Files = Application.GetOpenFilename _
(FileFilter:="CsVFile(*.xlsx), *.xlsx", MultiSelect:=True)
If IsArray(Files) Then
Set pBook = Workbooks.Add(xlWBATWorksheet)
FilesCnt = UBound(Files)
For i = 1 To FilesCnt
Workbooks.Open Files(i)
Set cBook = ActiveWorkbook
If i > 1 Then
cBook.ActiveSheet.UsedRange.Offset(1, 0).Copy
With pBook.ActiveSheet
.Range("A65536").End(xlUp).Offset(1). _
PasteSpecial (xlPasteAll)
End With
Else
cBook.ActiveSheet.UsedRange.Copy
With pBook.ActiveSheet
.Cells(.Range("A65536").End(xlUp).Row, 1). _
PasteSpecial (xlPasteAll)
End With
End If
Application.CutCopyMode = False
cBook.Close
Next i
End If
ActiveWorkbook.SaveAs Filename:="D:\Test.xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close Filename:="D:\Test.xlsx"
MsgBox "終了しました。"
Set cBook = Nothing: Set pBook = Nothing
End Sub
|
|