我有超过100个文本文件,我必须计算每个文本的行数.Column A列出文件名,位于指定的文件夹中E1.有几个文件有超过100万行,导致脚本运行的时间非常长.
Sub counter()
Dim fso As New FileSystemObject
Dim ts As TextStream
Dim longtext As String
Dim lines As Variant
Dim GoToNum As Integer
Dim Start As Integer
GoToNum = 2
Start = 3
Do Until IsEmpty(Cells(Start, 1))
GoToNum = GoToNum + 1
Start = Start + 1
Loop
For i = 3 To GoToNum
If Cells(i, 2).Value <= Cells(2, 5).Value Then
ConOrg = Cells(1, 4).Value & "\" & Cells(i, 1).Value
Set ts = fso.OpenTextFile(ConOrg, …Run Code Online (Sandbox Code Playgroud) select Values, REGEXP_COUNT(values,'|') from Products
Run Code Online (Sandbox Code Playgroud)
样本值单元格:
Product|Cash|Loan|Customer
Run Code Online (Sandbox Code Playgroud)
选择的结果是27。如果算其他字符,它可以工作,但是如果我要算| 它计算整个字符串。为什么,如何计数管道?