Extracting a number from a string

MikeJ100

New Member
Joined
Jan 30, 2017
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hi all I wish to get the number 1300012207166 from the following E S1 INSTALL 1300012207166 LL57 2EA

I have used the following =IF(SUM(LEN(A2)-LEN(SUBSTITUTE(A2,{"0","1","2","3","4","5","6","7","8","9"},"")))>0, SUMPRODUCT(MID(0&A2, LARGE(INDEX(ISNUMBER(--MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1)) * ROW(INDIRECT("1:"&LEN(A2))), 0), ROW(INDIRECT("1:"&LEN(A2))))+1, 1) * 10^ROW(INDIRECT("1:"&LEN(A2)))/10),"") thanks to Ablebits.com

and I get 11300012207166600.

I don't understand the formula, however I don't want the last two 00s.

Thanks for your help
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
This 2-formula procedure finds the largest number in the input string.

ABC
2E S1 INSTALL 1300012207166 LL57 2EA15.131300012207166

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
C2=TRIM(MID(A2,ROUND(MOD(B2,1)*100,0),B2))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
B2{=MAX(IF(ISNUMBER(MID(A2&"A",ROW(INDIRECT("1:"&LEN(A2))),TRANSPOSE(ROW(INDIRECT("1:"&LEN(A2)))))+0),TRANSPOSE(ROW(INDIRECT("1:"&LEN(A2))))+ROW(INDIRECT("1:"&LEN(A2)))/100))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



It returns the result as text so that Excel won't convert it to exponential notation. It's still possible to return false results depending on the data. If you know that the number that you're looking for must have a certain length, say 10-15 digits, you can shorten it as follows:

Code:
=MAX(IF(ISNUMBER(MID(A2&"A",ROW(INDIRECT("1:"&LEN(A2))),{10,11,12,13,14,15})+0),{10,11,12,13,14,15}+ROW(INDIRECT("1:"&LEN(A2)))/100))
with Control+Shift+Enter.
 
Upvote 0
Eric, Wow I don't understand the mechanics, but it works.

Thank you
 
Upvote 0
MikeJ100,

If cell A2 contains E S1 INSTALL 1300012207166 LL57 2EA

In cell C2 enter the following formula =TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",100)),300,100))
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,215
Members
448,554
Latest member
Gleisner2

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