Try this pasted into a standard module...
Sub GetLastData()
Dim sFilename$, vDataIn, vDataOut(), v
Dim lStart&, n&, k&, j&, lCols&
sFilename = Get_FileToOpen: If sfilename = "" Then Exit Sub
vDataIn = Split(ReadTextFileContents(sFilename), vbCrLf)
lStart = UBound(vDataIn) - 5000: If lStart < 0 Then lStart = 0
v = Split(vDataIn(0), ","): lCols = UBound(v) + 1
Redim vDataOut(1 To Ubound(vDataIn) + 1, 1 To lCols)
For n = lStart To UBound(vDataIn)
v = Split(vDataIn(n), ","): k = k + 1
For j = LBound(v) To UBound(v)
vDataOut(k, 1) = Split(vDataIn(n), ",")
Next 'j
Next 'n
With Range("A1").Resize(UBound(vDataOut), lCols)
.Value = vDataOut: .Columns.AutoFit
End With 'Range("A1").Resize
End Sub 'GetLastData
Function Get_FileToOpen$(Optional FileTypes$ = _
"All Files ""*.*"", (*.*)")
Dim v As Variant
v = Application.GetOpenFilename(FileTypes)
If (v = False) Then Get_FileToOpen = "" Else Get_FileToOpen = v
End Function 'Get_FileToOpen()
Function ReadTextFileContents$(Filename As String)
' Reads large amounts of data from a text file in one single step.
Dim iNum As Integer
On Error GoTo ErrHandler
iNum = FreeFile(): Open Filename For Input As #iNum
ReadTextFileContents = Space$(LOF(iNum))
ReadTextFileContents = Input(LOF(iNum), iNum)
ErrHandler:
Close #iNum: If Err Then Err.Raise Err.Number, , Err.Description
End Function 'ReadTextFileContents()
--
Garry
Free usenet access at
http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion