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
 
Examples of My string are :

1. Asia Pacific Billing ATT-14-015(eForm # 2028264)

2. Asia Pacific Billing ATT-14-018v2(eForm # 2029389)

3. Asia Pacific Billing -eForm # 2024585
If they are representative of your data (always 7 digits & always at the end of the string apart from possibly a ")"), then you may also be able to use just this.

Excel Workbook
AB
1Asia Pacific Billing ATT-14-015(eForm # 2028264)2028264
2Asia Pacific Billing ATT-14-018v2(eForm # 2029389)2029389
3Asia Pacific Billing -eForm # 20245852024585
Extract No
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
.. otherwise if there could be other text afterwards &/or other # symbols before the eForm, but the required numbers are still always 7 digits, then:

Excel Workbook
AB
1Asia Pacific Billing ATT-14-015(eForm # 2028264)2028264
2Asia Pacific Billing ATT-14-018v2(eForm # 2029389)2029389
3Asia Pacific Billing -eForm # 20245852024585
4ABC#ATT-14-015(eForm # 2028264) extra2028264
Extract No
 
Upvote 0
@manav1103 again,
Please read #13 of the Forum Rules, including the page linked at the end of that rule.
 
Upvote 0
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




Try this until length of the string : =IF(ISERR(MID(A8,1,1)*1>0),"",MID(A8,1,1))&IF(ISERR(MID(A8,2,1)*1>0),"",MID(A8,2,1))&IF(ISERR(MID(A8,3,1)*1>0),"",MID(A8,3,1))&IF(ISERR(MID(A8,4,1)*1>0),"",MID(A8,4,1))&IF(ISERR(MID(A8,5,1)*1>0),"",MID(A8,5,1))&IF(ISERR(MID(A8,6,1)*1>0),"",MID(A8,6,1))&IF(ISERR(MID(A8,7,1)*1>0),"",MID(A8,7,1))&IF(ISERR(MID(A8,8,1)*1>0),"",MID(A8,8,1))
 
Upvote 0
Try this until length of the string : =IF(ISERR(MID(A8,1,1)*1>0),"",MID(A8,1,1))&IF(ISERR(MID(A8,2,1)*1>0),"",MID(A8,2,1))&IF(ISERR(MID(A8,3,1)*1>0),"",MID(A8,3,1))&IF(ISERR(MID(A8,4,1)*1>0),"",MID(A8,4,1))&IF(ISERR(MID(A8,5,1)*1>0),"",MID(A8,5,1))&IF(ISERR(MID(A8,6,1)*1>0),"",MID(A8,6,1))&IF(ISERR(MID(A8,7,1)*1>0),"",MID(A8,7,1))&IF(ISERR(MID(A8,8,1)*1>0),"",MID(A8,8,1))
Welcome to the MrExcel board!

Do you realise that you are responding to somebody who asked their question more than 7 years ago! :)
 
Upvote 0
The VBA code extract multiple numbers only works on windows. Is there a similar VBA code for mac? Please find below the windows code:

Function Sep(txt As String, flg As Boolean) As String
With CreateObject("VBScript.RegExp")
.Pattern = IIf(flg = True, "\d+", "\D+")
.Global = True
Sep = .Replace(txt, "")
End With
End Function
 
Upvote 0
The VBA code extract multiple numbers only works on windows. Is there a similar VBA code for mac? Please find below the windows code:

Function Sep(txt As String, flg As Boolean) As String
With CreateObject("VBScript.RegExp")
.Pattern = IIf(flg = True, "\d+", "\D+")
.Global = True
Sep = .Replace(txt, "")
End With
End Function
Does this work for you...
Code:
Function Sep(txt As String, flg As Boolean) As String
  Dim X As Long, Pattern As String
  Pattern = "[" & IIf(flg, "!", "") & "0-9]"
  For X = 1 To Len(txt)
    If Mid(txt, X, 1) Like Pattern Then Sep = Sep & Mid(txt, X, 1)
  Next
End Function
 
Upvote 0
Does this work for you...
Code:
Function Sep(txt As String, flg As Boolean) As String
  Dim X As Long, Pattern As String
  Pattern = "[" & IIf(flg, "!", "") & "0-9]"
  For X = 1 To Len(txt)
    If Mid(txt, X, 1) Like Pattern Then Sep = Sep & Mid(txt, X, 1)
  Next
End Function

Many thanks Rick! This works perfect!
 
Upvote 0

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