Finding tabs in a string from a text file

  • Thread starter Thread starter SimonT
  • Start date Start date
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
 
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
 
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
 
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 *
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top