Natural solution in such situation would be by using RegEx (Regular Expressions).
Members of Insider program do have already access to such functions.
Unfortunately, standard Microsoft 365 users - not yet.
But we can use UDF (user defined Function) in VBA, and use it as normal function in the worksheet.
A code for such function (original source:
General Purpose UDFs for using Regular Expressions in Excel ) could look like that:
VBA Code:
Public Function RXMatches(Text As String, Pattern As String, Optional Group As Integer = 0, Optional IgnoreCase As Boolean = True) As Variant
Dim retval() As String, i As Long
' from
' Takes a string and returns all matches in a vertical array
' Text is the string to be searched
' Pattern is the regex pattern
' Group (optional) selects a parenthesized group (count the number of left parentheses preceding it to get the group number)
' IgnoreCase (optional) set to False for a case-sensitive search
Dim RE As Object
Dim Matches As Object
Set RE = CreateObject("vbscript.regexp")
RE.IgnoreCase = IgnoreCase
RE.Global = True
RE.Pattern = Pattern
Set Matches = RE.Execute(Text)
If (Matches.Count > 0) Then
ReDim retval(0 To Matches.Count - 1)
For i = 0 To Matches.Count - 1
If (Group > 0) Then
retval(i) = Matches(i).submatches(Group - 1)
Else
retval(i) = Matches(i)
End If
Next i
Else
ReDim retval(1)
retval(0) = ""
End If
RXMatches = Application.Transpose(retval)
End Function
And the use in the worksheet would be:
=TRANSPOSE(RXMatches(A2,"([\D]+\s|\d*,\d*)"))
This string: "([\D]+\s|\d*,\d*)" defines a pattern for searching. If you want to have it explained - write it (without quotation marks) in "formula bar" on
regex101: build, test, and debug regex and sample of your text in the window below