Code to import from txt to excel

Giganews Newsgroups
Subject: Code to import from txt to excel
Posted by:  N.F
Date: Tue, 7 Aug 2007

Any help, highly appreciated:

I am trying to get a macro to import a text file in a table format into excel
I have the following code but this code does not give me the format properly:

Sub importtext()
x = 1
Open "c:\trial.txt" For Input As #1
Do While Not EOF(1)
Input #1, Line
Worksheets("sheet1").Cells(x, 1).Value = Line
x = x + 1
Loop
Close #1
End Sub

Replies