'应该差不多,自己试一下
Option Explicit
Sub test()
Dim arr, i, t, mark, n
mark = "$DataGridSelectionId"
Open ThisWorkbook.Path & "\代码.txt" For Input As #1
arr = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbNewLine)
Close #1
ReDim brr(1 To UBound(arr) - 1, 1 To 3)
For i = 0 To UBound(arr)
If InStr(arr(i), mark) Then
n = n + 1
brr(n, 1) = Split(arr(i), "name=")(1)
brr(n, 1) = Split(brr(n, 1))(0)
t = Split(arr(i + 1), "</TD>")(0)
t = Split(t, ">")
brr(n, 2) = Trim(t(UBound(t)))
t = Split(arr(i + 2), "</TD>")(0)
t = Split(t, ">")
brr(n, 3) = Trim(t(UBound(t)))
i = i + 2
End If
Next
With [a2]
.Resize(Rows.Count - 1, UBound(brr, 2)).ClearContents
If n > 0 Then .Resize(n, UBound(brr, 2)) = brr
End With
End Sub |