JH,
You can also modify the code given in Eric's link to use only one sheet. If
your text file is less than 16,777,216 lines you can use the following code
that will import lines up to 65536 into the first column and then lines
65537-131072 into the second column and so on until the end of file. This is
usefull if you don't want a bunch of sheets created. I've never reached the
limit before and I've processed files up to 1GB that use roughly 32 columns.
Code follows:
Sub Importfile()
Dim FileName As String
Dim ResultStr As String
Dim FileNum As Integer
Dim Counter As Double
FileName = Application.GetOpenFilename
Application.ScreenUpdating = False
If FileName = "False" Then End
FileNum = FreeFile()
Open FileName For Input As #FileNum
Sheet1.Cells(65000, 1).Select
Counter = 1
ColCounter = 1
Do While Seek(FileNum) <= LOF(FileNum)
If EOF(FileNum) Then End
Application.StatusBar = "Reading Row " & Counter & " of text file " &
FileName
Line Input #FileNum, ResultStr
ActiveCell.Value = ResultStr
If ActiveCell.Row = 65536 Then
ColCounter = ColCounter + 1
Sheet1.Cells(1, ColCounter).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Counter = Counter + 1
Loop
Close
Application.ScreenUpdating = True
Application.StatusBar = False
End Sub
Hope this helps,
Mike