Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

readind .txt file into excel worksheet, line by line 2

Status
Not open for further replies.

ipupkin

Technical User
Jul 29, 2002
26
NL
Hi, All

I need to read .txt file into excel worksheet, line by line. The first line into cell A1, the second line into cell A2, and so on.

This will be done by macros, which receives file name as parameter and starting cell as a second parameter.

What function is better to use to read .txt file line by line?
 
Something like this ?
Open myPathName For Input As #1
Do While Not EOF(1)
Line Input #1, TextLine
Debug.Print TextLine
Loop
Close #1

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Why did you not search this forum before posting?

There are several threads with this info including thread 707-714094!!.

Another way more usefull than the above thread if the file is not delimited, is to open the file normally (for you to see the code please record a macro, where you open the text file, apply the import rules (e.g. delimited/fixed , delimiter, column formatting) and then look at the VB code created), and then select all the lines read, and copy/paste them into the destination cell (AND there is also some threads about copy/paste in VBA. Search for them!!).





Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top