0

I'm importing a csv to Excel 2016 - using GetData from Text/CSV so I can predict datatypes, otherwise columns with hex codes come through as garbage

But it's creating new rows wherever there are entries that have newline characters, even though these are inside quotation marks e.g.

123 | "Hello.<newline>My name is Jam" | a3e3f3

is being parsed out as

123              | Hello.
My name is Jam   | 

I found several suggestions from a very old thread using Excel 2007 -

Importing CSV with line breaks in Excel 2007

but specifying UTF-8 doesn't work...

I've tried recording the VBA for it to look for variables I can change:

With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
    "OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=""MyWorkBook"";Extended Properties="""""), Destination:=Range("$A$1")).QueryTable
    .CommandType = xlCmdSql
    .CommandText = Array( _
    "SELECT * FROM [MyWorkbook]")
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .PreserveColumnInfo = True
    .ListObject.DisplayName = _
    "MyWorkbook"
    .Refresh BackgroundQuery:=False
End With

Doesn't look like there's anything in there I can change to say "IGNORE LINEBREAKS INSIDE COMMAS"

jamheadart
  • 5,047
  • 4
  • 32
  • 63

0 Answers0