This function will work on your data, it's a new formula you can use in this workbook.
Option Explicit
Function NUMSTR(RNG As Range, Optional Delim As String) As String
'Author: Jerry Beaucaire
'Date: 8/24/2010
'Summary: Pull numeric strings out of text strings, list delimited
Dim MyArr As Variant
Dim i As Long
Dim x As Long
Dim cell As Range
Dim Buf As String
Dim Num As String
If Delim = "" Then Delim = ","
For Each cell In RNG
MyArr = Split(cell, " ")
For i = LBound(MyArr) To UBound(MyArr)
If IsNumeric(Left(MyArr(i), 1)) Then
For x = 1 To Len(MyArr(i))
If IsNumeric(Mid(MyArr(i), x, 1)) Then _
Num = Num & Mid(MyArr(i), x, 1) ' Leave only numbers
Next x
If Buf = "" Then Buf = Num Else Buf = Buf & Delim & Num
Num = ""
End If
Next i
Next cell
NUMSTR = Buf
End Function
How to install the User Defined Function:
1. Open up your workbook
2. Get into VB Editor (Press Alt+F11)
3. Insert a new module (Insert > Module)
4. Copy and Paste in your code (given above)
5. Get out of VBA (Press Alt+Q)
6. Save as a macro-enabled workbook
=============
The function is used in an empty cell like so:
=NUMSTR(A1)
=NUMSTR(A1:A3)
...or
=NUMSTR(A1, ",")
=NUMSTR(A1:A3, "-")
This newer version lets you put the delimiter to use as an optional second parameter.
The function will search all the words in your text string and try to determine which are numeric and display ALL of them in a delimited string.
Attached is a sample workbook with the UDF installed and demonstrated for you.
Bookmarks