[VBA]提取指定字符串后的数字--代码来源Excelhome
问题:提取check之后的数字
来源:Excelhome
Sub 提取数字()
Dim regexp As New regexp
With regexp
.Pattern = "check\s*(\d+)"
End With
With Worksheets("sheet1")
r = .Cells(.Rows.Count, 1).End(xlUp).Row
arr = .Range("a1:b" & r)
For i = 1 To UBound(arr)
Set mh = regexp.Execute(arr(i, 1))
arr(i, 2) = mh(0).SubMatches(0)
Next
.Range("a1:b" & r) = arr
End With
End Sub