how do I concatenate multiple CSV files into one?
Robin,
Put the code below into an otherwise blank workbook, then run the macro, and select the files that
you want to combine when the file selection dialog appears.
HTH,
Bernie
MS Excel MVP
Sub ConsolidateMultipleUserSelectedFiles()
Dim FileArray As Variant
Dim myBook As Workbook
Set myBook = ThisWorkbook
FileArray = Application.GetOpenFilename(MultiSelect:=True)
If IsArray(FileArray) Then
For i = LBound(FileArray) To UBound(FileArray)
Workbooks.OpenText Filename:=FileArray(i), Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _
Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(1, 1)
Range("A1").CurrentRegion.Copy myBook.Worksheets(1).Range("a65536").End(xlUp).Off set(1, 0)
ActiveWorkbook.Close False
Next i
End If
myBook.Save
End Sub
"RobinC" wrote in message
...
I have a bunch of single line CSV files (without even new line characters on
the end) that I want to concatenate into a single file, which I then want to
work with in excel.
How can I do this?
|