Finding tabs in a string from a text file

S

SimonT

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
 
Y

yogendra joshi

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
 
M

mjclare

Simon,

The tab character is the 9th ASCII value so... modify your statement t
be: ... -Instr(1, WorkResult, chr(9))

Mike
*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
 
D

Dave Peterson

or even

-Instr(1, WorkResult, vbTab)



mjclare < said:
Simon,

The tab character is the 9th ASCII value so... modify your statement to
be: ... -Instr(1, WorkResult, chr(9))

Mike
*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 *
 
Top