Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Annie Russell   on Jan 01 In MS Office Category.

  
Question Answered By: Spiru Kelly   on Jan 01

I have the following contents in a text  file
5 6
7 8
9 1
2 3
4 6
1 3
4 6
4 7
4 6

the file  is also saves as nos.txt , saved under
"C:\Documents and Settings\Birumanand\Desktop\"

This should work...

Sub Read_write()

Dim iPath As String
Dim iRunner As Long

iPath = "C:\Documents and
Settings\Birumanand\Desktop\"

X = 0
Open iPath & "nos.txt" For Input As #1

Line Input #1, St

While Not EOF(1)
X = X + 1
Sheets(1).Cells(X, 1) = Left(St, 1)
Sheets(1).Cells(X, 2) = Right(St, 1)

Line Input #1, St


Close #1


Open iPath & "output.txt" For Output As #1

For iRunner = 1 To
Sheets(1).Cells.SpecialCells(xlCellTypeLastCell).Row()

Print #1, Trim(Sheets(1).Cells(iRunner, 1) *
Sheets(1).Cells(iRunner, 2))

Next


Close #1

End Sub


let me know, is that what you were looking for...

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on write to text files Or get search suggestion and latest updates.


Tagged: