Open csv file delimited by pipe character “|” or n

2020-04-05 07:04发布

I'm trying to set up an Excel VBA code that opens up some .csv files and split into columns the information contained and delimited by the character |. I manage to open the file but the code I use opens my files without splitting the text according to the delimiter. So far I have tried the following code:

Sub OpenCSV()

Dim wkbTemp As Workbook
Dim sPath As String, sName As String

sPath = ThisWorkbook.Path & "\CSV_Files\"
sName = "Test.csv"

Set wkbTemp = Workbooks.Open(Filename:=sPath & sName, Format:=6, Delimiter:="|")

End Sub

7条回答
一夜七次
2楼-- · 2020-04-05 07:56

Try it with

Delimiter:= Chr(124)

Character 124 is the pipe "|"

查看更多
登录 后发表回答