|
こんにちは。
複数のcsvを結合したいのですが、2つ目以降のcsvのタイトル行を削除しつつ結合したいとき、どうすればよろしいでしょうか。
よろしくお願いします。
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
cBook.ActiveSheet.UsedRange.Copy
' With ActiveSheet.QueryTables.Add(Connection:= _
' "TEXT;" & fname, Destination:=Range("A2"))
With pBook.ActiveSheet
.Cells(.Range("A65536").End(xlUp).Row, 1). _
PasteSpecial (xlPasteAll)
End With
Application.CutCopyMode = False
cBook.Close
Next i
End If
Set cBook = Nothing: Set pBook = Nothing
End Sub
|
|