![]() |
Finding tabs in a string from a text file
I have a tab delimited text file which has too many
columns so I am trying to right some code to put the remaining columns onto another worksheet in excel. I have got some code which works for a comma delimited text file, but I can't seem to get the same bit of code to work with a tab delimited file. I am trying to get it to recognise the tab in an Instr statement. My current line of code is: WorkResult = Right(WorkResult, Len (WorkResult) - Instr(1, WorkResult, ",")) Changing the "," to "{tab}" or "[tab]" doesn't work, anyone with any ideas, please let me know Thanks SimonT |
Finding tabs in a string from a text file
Can following code hel you?
Sub import() Workbooks.OpenText Filename:="d:/test.txt", _ DataType:=xlDelimited, tab:=True End Sub This imports a tab determined file :) Let me know SimonT wrote: I have a tab delimited text file which has too many columns so I am trying to right some code to put the remaining columns onto another worksheet in excel. I have got some code which works for a comma delimited text file, but I can't seem to get the same bit of code to work with a tab delimited file. I am trying to get it to recognise the tab in an Instr statement. My current line of code is: WorkResult = Right(WorkResult, Len (WorkResult) - Instr(1, WorkResult, ",")) Changing the "," to "{tab}" or "[tab]" doesn't work, anyone with any ideas, please let me know Thanks SimonT |
Finding tabs in a string from a text file
Simon,
The tab character is the 9th ASCII value so... modify your statement t be: ... -Instr(1, WorkResult, chr(9)) Mike SimonT wrote: *I have a tab delimited text file which has too many columns so I am trying to right some code to put the remaining columns onto another worksheet in excel. I have got some code which works for a comma delimited text file, but I can't seem to get the same bit of code to work with a tab delimited file. I am trying to get it to recognise the tab in an Instr statement. My current line of code is: WorkResult = Right(WorkResult, Len (WorkResult) - Instr(1, WorkResult, ",")) Changing the "," to "{tab}" or "[tab]" doesn't work, anyone with any ideas, please let me know Thanks SimonT -- Message posted from http://www.ExcelForum.com |
Finding tabs in a string from a text file
or even
-Instr(1, WorkResult, vbTab) "mjclare <" wrote: Simon, The tab character is the 9th ASCII value so... modify your statement to be: ... -Instr(1, WorkResult, chr(9)) Mike SimonT wrote: *I have a tab delimited text file which has too many columns so I am trying to right some code to put the remaining columns onto another worksheet in excel. I have got some code which works for a comma delimited text file, but I can't seem to get the same bit of code to work with a tab delimited file. I am trying to get it to recognise the tab in an Instr statement. My current line of code is: WorkResult = Right(WorkResult, Len (WorkResult) - Instr(1, WorkResult, ",")) Changing the "," to "{tab}" or "[tab]" doesn't work, anyone with any ideas, please let me know Thanks SimonT * --- Message posted from http://www.ExcelForum.com/ -- Dave Peterson |
All times are GMT +1. The time now is 12:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com