
You can count the Lines
in a File!
VBA Code
For example, count following “text file“:
hogehoge1
hogehoge2
hogehoge3
hogehoge4
hogehoge5


Option Explicit
Sub sampleProc()
Dim fso As Object
Dim fileName As String
Dim lineCount As Long
'Set "file path"
fileName = "C:\Users\user\Desktop\hogehoge.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
'Count the Lines in a File
lineCount = fso.OpenTextFile(fileName:=fileName, iomode:=8).Line
MsgBox lineCount & " Lines."
Set fso = Nothing
End Sub
Result
You counted the Lines in a File!

FYI
For more information about following, see the following official online manual:
●“OpenTextFile method” of “FileSystemObject”
●“Line property” of “TextStream Object”