下面的代码就可以:
可以录制宏来修改,所有代码的文本为:
Option Explicit
Sub 宏1()
Dim arr(1 To 1000, 1 To 2), cnt%
Dim p$, f$, t$, line$
p = "i:\Temp\tmp\" 'TXT所在文件夹,必须以\结尾
f = Dir(p & "*.txt")
While f <> ""
line = ""
Open p & f For Input As #1
Line Input #1, t
If Left(t, 2) = "小计" Then line = t
Close #1
cnt = cnt + 1
arr(cnt, 1) = f
arr(cnt, 2) = line
f = Dir
Wend
If cnt > 0 Then Range("a1").Resize(cnt, 2) = arr
End Sub