|
Option Explicit
Sub TEST1()
Dim ar, br, i&, j&, strTxt$
ar = Sheets(1).[A1].CurrentRegion.Value
With [A1].CurrentRegion
.Offset(1).Clear
br = .Resize(UBound(ar))
End With
With CreateObject("VBScript.RegExp")
For i = 2 To UBound(ar)
br(i, 1) = ar(i, 1)
For j = 2 To UBound(br, 2)
strTxt = IIf(br(1, j) = "现金", "门诊预缴金", br(1, j))
.Pattern = strTxt & ".+?" & "([0-9\.]+)"
If .test(ar(i, 2)) Then br(i, j) = .Execute(ar(i, 2))(0).submatches(0)
Next j
Next i
End With
[A1].Resize(UBound(br), UBound(br, 2)) = br
Beep
End Sub
|
|