仅使用";"打开.csv文件作为分隔符

时间:2016-10-27 18:51:26

标签: excel excel-vba csv separator vba

我正在使用CREATE TABLE pivot_dealer AS SELECT 'Monday' AS day, Mopen AS Open, Mclosed AS Closed, Dealer FROM Dealer UNION ALL SELECT 'Tuesday' AS day, Topen AS Open, Tclosed AS Closed, Dealer FROM Dealer UNION ALL SELECT 'Wednesday' AS day, Wopen AS Open, Wclosed AS Closed, Dealer FROM Dealer UNION ALL SELECT 'Thursday' AS day, Thopen AS Open, Thclosed AS Closed, Dealer FROM Dealer UNION ALL SELECT 'Friday' AS day, Fopen AS Open, Fclosed AS Closed, Dealer FROM Dealer UNION ALL SELECT 'Saturday' AS day, Sopen AS Open, Sclosed AS Closed, Dealer FROM Dealer UNION ALL SELECT 'Sunday' AS day, Suopen AS Open, Suclosed AS Closed, Dealer FROM Dealer ; _从http链接打开一个.csv文件,并且它得到了所有错误,因为Excel将逗号解释为列分隔符而不是&#34 ;;"这是表格使用的。

我怎么能让vba代码将逗号解释为小数分隔符,如0,5 = 5/10和&#34 ;;"当我打开这个文件时签名作为列分隔符?

2 个答案:

答案 0 :(得分:0)

我查了一下,如果你去excel的数据菜单然后选择导入文本文件,请按照向导选择分号作为分隔符

答案 1 :(得分:0)

你试过这个:
Workbooks.OpenText filename:=http://XXX/FIlename.csv, _ DataType:=xlDelimited, Semicolon:=True

而不是:
Workbooks.Open Filename:= _ "http://XXX/FIlename.csv", Delimiter:=";"