Importing text file into worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would be the best way to import a non-delimited text file (cannot be changed) into a worksheet

Here is an example of the text file
http://68.230.14.172:81/Monthly Billing 103103.tx

I am a new programmer that doesn't know that much about this yet. Should I do this as a string as separate it according to the format of the text? If I just do a standard import through the Data menu, it splits words and everything

Any suggestions

Sincerely
Steve
 
If importing as a fixed width is not suitable then you would need t
import the file line by line


example importing your file using fixed width - it does split som
header words.

Workbooks.OpenText FileName:="D:\Monthly Billing 103103.txt"
Origin:= _
xlWindows, StartRow:=1, DataType:=xlFixedWidth
FieldInfo:=Array(Array(0, _
1), Array(4, 2), Array(16, 2), Array(49, 2), Array(61, 2)
Array(72, 2), Array(84, 2), Array _
(102, 2), Array(114, 2), Array(127, 2), Array(142, 2)
Array(154, 2), Array(170, 2), Array( _
197, 2))


example importing your file line by line

dim rCnt as long

Open :="D:\Monthly Billing 103103.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, stxt
rcnt = rcnt + 1
if isnumeric(mid(stxt,8,6)) then
cells(rcnt,"b")=mid(stxt,5,12)
cells(rcnt,"c")=trim(mid(stxt,18,34))
cells(rcnt,"d")=mid(stxt,52,10)
etc
etc
etc
else
cells(rcnt,"a")=stxt

loo
 
Back
Top