S
Steve
and put that number into a excel cell?????
I would love to know how to do that. . . .
I would love to know how to do that. . . .
Jake Marx said:Hi Steve,
You could use the FileSystemObject in a user-defined function (UDF) like
this:
Public Function GetLineCount(rsPath As String) As Variant
Dim fso As Object
On Error GoTo ErrHandler
Set fso = CreateObject("scripting.filesystemobject")
With fso.OpenTextFile(rsPath)
If Not .AtEndOfStream Then
.ReadAll
GetLineCount = .Line
Else
GetLineCount = 0
End If
.Close
End With
ExitRoutine:
Set fso = Nothing
Exit Function
ErrHandler:
GetLineCount = CVErr(1004)
Resume ExitRoutine
End Function
Then, from an cell, you could do this:
=GETLINECOUNT("C:\test.txt")
--
Regards,
Jake Marx
MS MVP - Excel
www.longhead.com
[please keep replies in the newsgroup - email address unmonitored]
and put that number into a excel cell?????
I would love to know how to do that. . . .
Dana said:Hi Jake. Just to share programming ideas. I have found that reading
in a very large file (via ReadAll, or just looping) can slow the
program down a little.