如题所述
Sub test()
Dim arr() As String
Dim oRegExp As Object
Dim oMatches As Object
Dim iNum As Integer
'å®ä¹æ£å对象'
Set oRegExp = CreateObject("vbscript.regexp")
Dim iRow As Integer
iRow = Sheets(1).UsedRange.Rows.Count
For ind = 1 To iRow
arr = Split(Sheets(1).Cells(ind, 1).Value, "*")
iNum = UBound(arr) - LBound(arr)
For i = 0 To iNum
With oRegExp
.Global = True
.IgnoreCase = True
.Pattern = "[0-9]+"
Set oMatches = .Execute(arr(i))
End With
Sheets(1).Cells(ind, i + 2).Value = oMatches(0)
Sheets(1).Cells(ind, 8).Value = Sheets(1).Cells(ind, 8).Value + CInt(oMatches(0))
Set oMatches = Nothing
Next
Next
End Sub
Dim arr() As String
Dim oRegExp As Object
Dim oMatches As Object
Dim iNum As Integer
'å®ä¹æ£å对象'
Set oRegExp = CreateObject("vbscript.regexp")
Dim iRow As Integer
iRow = Sheets(1).UsedRange.Rows.Count
For ind = 1 To iRow
arr = Split(Sheets(1).Cells(ind, 1).Value, "*")
iNum = UBound(arr) - LBound(arr)
For i = 0 To iNum
With oRegExp
.Global = True
.IgnoreCase = True
.Pattern = "[0-9]+"
Set oMatches = .Execute(arr(i))
End With
Sheets(1).Cells(ind, i + 2).Value = oMatches(0)
Sheets(1).Cells(ind, 8).Value = Sheets(1).Cells(ind, 8).Value + CInt(oMatches(0))
Set oMatches = Nothing
Next
Next
End Sub
温馨提示:答案为网友推荐,仅供参考