Option Explicit
Sub TEST1()
Dim ar, br, vResult$(), i&, j&, aMatch As Object
ar = Range("D1", Cells(Rows.Count, "E").End(xlUp)).Value
ReDim vResult(1 To UBound(ar), 3)
br = Split("单位名称 内容 发票号 代码")
For j = 0 To UBound(br)
vResult(1, j) = br(j)
Next j
With CreateObject("VBScript.RegExp")
.Pattern = "([\u4e00-\u9fa5\,]+)([\d+\,\-]+)"
For i = 2 To UBound(ar)
br = Split(ar(i, 1))
vResult(i, 0) = br(0)
If .test(br(1)) Then
Set aMatch = .Execute(br(1))(0)
vResult(i, 1) = aMatch.submatches(0)
vResult(i, 2) = aMatch.submatches(1)
End If
vResult(i, 3) = ar(i, 2)
Next i
End With
Columns("K:N").Clear
[K1].Resize(UBound(vResult), 4) = vResult
Beep
End Sub
|