This one will import text file as comma Delimited data.
if you want data in text file in one line as whole into one cell, this
will not work as it is.
but try this
Sub textfileread()
Dim filename
Dim FileNum As Integer
Dim Counter As Long, maxrow As Long
Dim WorkResult As String
Dim startnum As Long, endnum As Long
Dim co As Long
On Error GoTo ErrorCheck
startnum = 161237 <<== change this
endnum = 161267 <<== change this
co = 0
maxrow = Cells.Rows.Count
filename = Application.GetOpenFilename(FileFilter:="All File
(*.*),*")
If VarType(filename) = vbBoolean Then
Exit Sub
End If
Application.ScreenUpdating = False
Application.EnableEvents = False
Counter = Cells(Cells.Rows.Count, "a").End(xlUp).Row
If Counter <> 1 Then
Counter = Counter + 1
End If
FileNum = FreeFile()
Open filename For Input As #FileNum
Do While Not EOF(FileNum)
Line Input #FileNum, WorkResult
co = co + 1
If co > endnum Then
Exit Do
ElseIf co >= startnum Then
If WorkResult <> "" Then
Cells(Counter, 1) = """" & WorkResult
Cells(Counter, 1).TextToColumns _
Destination:=Cells(Counter, 1), _
DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False,
Semicolon:=False, _
Comma:=True, Space:=False, Other:=False
End If
Counter = Counter + 1
If Counter > maxrow Then
MsgBox "data have over max rows"
Exit Do
End If
End If
Loop
Close FileNum
Application.EnableEvents = True
Application.ScreenUpdating = True
Exit Sub
ErrorCheck:
Application.EnableEvents = True
Application.ScreenUpdating = True
MsgBox "An error occured in the code."
End Sub
keizi