Opening CSV in Excel using VBA causes data to appear in two columns instead of one

后端 未结 5 1632
闹比i
闹比i 2021-01-20 12:17

I created VBA code in Excel 2007/2010 to import data from a CSV file. Unfortunately, when I open the file programmatically, the data is split into two columns (A and B) for

5条回答
  •  梦谈多话
    2021-01-20 12:38

    I think when you do it manually Excel is reading the delimiter as ";" and not just ;.

    Try this:

    Workbooks.Open Filename:=wkbCsvImport, Format:=xlDelimited, Delimiter:=""";"""
    

    EDIT:

    the only way I can get this to work is by changing the file extension from csv to txt and then run this code:

    Workbooks.OpenText Filename:=wkbCsvImport, _
                        DataType:=xlDelimited, semicolon:=True
    

提交回复
热议问题