write a line from Excel to a text file

J

julian_bro

Having tested for the correct 'key word' , when found i want to write
out the whole row to a new file.

While Worksheets(1).Cells(irowcount, 1) <> ""
If InStr(1, Worksheets(1).Cells(irowcount, 1), "STATION",
vbTextCompare) > 0 Then
ts.writeline Worksheets(1).irowcount
End If

This line doesn't work

ts.writeline Worksheets(1).irowcount
nor does
ts.writeline Worksheets(1).cells(irowcount,1:40)

can any one help

Julian brotheton.
 
P

Paul D

writeline needs a string
how about
ts.writeline Worksheets(1).cells(irowcount,1).value
if you are trying to write the values from columns 1 to 40 use a for loop
for i = 1 to 40
ts.writeline Worksheets(1).cells(irowcount,i).value
next i
of course this creates 40 lines of text. You may want to look at the write
# if you are looking for delimited data

Paul D
 

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

Top