В VBA вы можете использовать для этого регулярное выражение -> Использовать выражение регулярного выражения: "(\ d +)"
Вот функция, которая может использоваться для этого.
Public Function RegexExtractAll(ByVal text As String, _
ByVal extract_what As String, _
Optional separator As String = "") As String()
' This function takes a text, a regex expression and an optional separator character (default is "").
' It uses vbscript.regexp to delivers all matches and sub matches of the regex as a string array.
Dim allMatches As Variant
Dim RE As Object
Set RE = CreateObject("vbscript.regexp")
Dim i As Long, j As Long
Dim result() As String
RE.Pattern = extract_what
RE.Global = True
On Error Resume Next
Set allMatches = RE.Execute(text)
If Not (IsEmpty(allMatches) Or (allMatches.Count = 0)) Then
ReDim result(allMatches.Count - 1)
For i = 0 To allMatches.Count - 1
For j = 0 To allMatches.Item(i).submatches.Count - 1
result(i) = result(i) & (separator & allMatches.Item(i).submatches.Item(j))
Next
Next
End If
RegexExtractAll = result
End Function 'RegexExtractAll
Дляпроверить, что это работает:
Sub SomeTest()
' The RegexExtractAll will return an array with the matches.
' By using Join() we merge them to one string.
Debug.Print Join(RegexExtractAll("655.44,32", "(\d+)"), "")
End Sub