Re: [問題] VBA讀取TXT格式問題

作者: aup65797 (有緣人)   2016-07-09 20:59:41
Sub test()
Dim qt As QueryTable
Set qt = ActiveSheet.QueryTables.Add("TEXT;d:\20160703.txt", [a1])
With qt
.AdjustColumnWidth = False
.TextFileParseType = xlDelimited
.TextFileTabDelimiter = True
.TextFileCommaDelimiter = True
.Refresh
End With
End Sub
用以上方式 , excel讀取會空一格 , 麻煩大大
https://www.dropbox.com/s/4uxgfuykhl0h6ix/VBA%20TAB%20format.PNG?dl=0
作者: soyoso (我是耀宗)   2016-07-09 21:18:00
加上textfileconsecutivedelimiter=true 試試
作者: azteckcc ( )   2016-07-09 21:18:00
把你的 TXT 傳上來,個人猜你的txt裡可能會有狀況,比如同時有分隔符同時有tab和逗號
作者: aup65797 (有緣人)   2016-07-09 21:27:00
作者: soyoso (我是耀宗)   2016-07-09 21:41:00
測試上將連結內TextFileTabDelimiter改為true再加上回文第一筆的部分,應可https://imgur.com/LGBAe2D

Links booklink

Contact Us: admin [ a t ] ucptt.com