Extracting Multiple Numbers from String

bolillo1234

New Member
Joined
Jan 5, 2009
Messages
5
I have thousands of fields that contain addresses and I need to extract only the numbers. The problem I am facing is that there are two numbers within the string and they begin at different times.

Examples of the data
1409 N 250 W
259 West 158 Johnson Blvd
109829 South 344 East

What Im trying to get
1409250
259158
109829344

Thanks,
Bolillo
 
@djmyers

You originally asked about a formula solution without the digit count limit. If you happen to have Office 365 with the CONCAT function then you could use a formula like B1 to use the space delimiter or C1 to use any text as delimiter.
Each of these is an array formula so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}.

I have also suggested another UDF that doesn't require looping through the individual characters of the string. Examples of use in D1:E1.

Code:
Function GetDigits(s As String, Optional sDel As String = " ") As String
  With CreateObject("VBScript.RegExp")
    .Global = True
    .Pattern = "\D+"
    GetDigits = Replace(Application.Trim(.Replace(s, " ")), " ", sDel)
  End With
End Function


Book1
ABCDE
1GNCP 638, 2014 Fall Placemats GFI , NORAD, 9/1-12/31/14638 2014 9 1 12 31 14638 - 2014 - 9 - 1 - 12 - 31 - 14638 2014 9 1 12 31 14638, 2014, 9, 1, 12, 31, 14
Sheet1
Cell Formulas
RangeFormula
D1=GetDigits(A1)
E1=GetDigits(A1,", ")
B1{=TRIM(CONCAT(IFERROR(MID(A1,ROW(INDEX(A:A,1):INDEX(A:A,LEN(A1))),1)+0," ")))}
C1{=SUBSTITUTE(TRIM(CONCAT(IFERROR(MID(A1,ROW(INDEX(A:A,1):INDEX(A:A,LEN(A1))),1)+0," ")))," "," - ")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,022
Latest member
RobertV1609

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top