|
楼主 |
发表于 2022-9-24 09:55
|
显示全部楼层
问题已被朋友解决。贴出代码:
Sub test()
Dim x As Integer, y As Integer, m As Integer, n As Integer, TextLine As String
x = 2
For m = 1 To 2
For n = 1 To 12
Open ThisWorkbook.Path & "\" & m & "-" & n & ".log" For Input As #1
y = 1
Do While Not EOF(1)
Line Input #1, TextLine
If TextLine Like "*NUMBER*" Then
Sheets("sheet1").Cells(x, y) = Mid(TextLine, InStr(TextLine, "210") - 1)
y = y + 1
End If
Loop
Close #1
x = x + 1
Range("a65535").End(xlUp).Offset(1, 0).Select
Next n
Next m
End Sub
这回24个文件都可以被打开,抓取指定字符串并输入到excel,实现脚本录入了 |
|