|
▼kanabunさん、UO3 さん:
アドバイスまことにありがとうございます。
行を削除するので
cBook.ActiveSheet.UsedRange.Offset(1, 0).Copy
でございますよね。
アドバイスを参考に下記の通りできました。
深く感謝いたします。
Sub Test()
Dim Files, FilesCnt As Integer, i As Integer
Dim cBook As Workbook, pBook As Workbook
Files = Application.GetOpenFilename _
(FileFilter:="CsVFile(*.csv), *.csv", 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
Else
cBook.ActiveSheet.UsedRange.Copy
End If
With pBook.ActiveSheet
.Cells(.Range("A65536").End(xlUp).Row, 1). _
PasteSpecial (xlPasteAll)
End With
Application.CutCopyMode = False
cBook.Close
Next i
End If
'追加
ActiveWorkbook.SaveAs Filename:="C:\Digital_yyyymmdd.csv", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close Filename:="C:\Digital_yyyymmdd.csv"
MsgBox "終了しました。"
Set cBook = Nothing: Set pBook = Nothing
End Sub
|
|