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

看板Office作者 (有緣人)時間9年前 (2016/07/09 20:59), 編輯推噓0(0010)
留言10則, 3人參與, 最新討論串3/3 (看更多)
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 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.241.96.6 ※ 文章網址: https://www.ptt.cc/bbs/Office/M.1468069184.A.DB2.html

07/09 21:18, , 1F
加上textfileconsecutivedelimiter=true 試試
07/09 21:18, 1F

07/09 21:18, , 2F
把你的 TXT 傳上來,個人猜你的txt裡
07/09 21:18, 2F

07/09 21:20, , 3F
可能會有狀況,比如同時有分隔符同時有tab和逗號
07/09 21:20, 3F

07/09 21:28, , 6F
還是一樣不行ㄟ
07/09 21:28, 6F

07/09 21:31, , 7F
就是同時有逗號和Tab
07/09 21:31, 7F

07/09 21:38, , 8F
成功了..感謝S大
07/09 21:38, 8F

07/09 21:41, , 9F
測試上將連結內TextFileTabDelimiter改為true再加上回文第
07/09 21:41, 9F

07/09 21:42, , 10F
一筆的部分,應可https://imgur.com/LGBAe2D
07/09 21:42, 10F
文章代碼(AID): #1NWFL0so (Office)
文章代碼(AID): #1NWFL0so (Office)