Finding the NUMBER within a string

dwarnimont

Board Regular
Joined
Jan 12, 2010
Messages
71
What creative formula will be able to find and extract only the number from a cell with string like this: abc1233efg. Answer is 1233. length and number of characters is not fixed.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
=lookup(9.999999999e+307,mid(a1,min(find({0,1,2,3,4,5,6,7,8,9},a1&"0123456789")),{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15})+0)


Excel 2010
AB
1abc1233efg1233
2a14z14
3This one is 2323
Sheet1
Cell Formulas
RangeFormula
B1=LOOKUP(9.999999999E+307,MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15})+0)
B2=LOOKUP(9.999999999E+307,MID(A2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789")),{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15})+0)
B3=LOOKUP(9.999999999E+307,MID(A3,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A3&"0123456789")),{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15})+0)
 
Last edited:
  • Like
Reactions: shg
Upvote 0
This is insane!!!! I cant believe you created it. I'd love to understand the pieces better. Where might i go to learn the components of this formula?
 
Upvote 0
On your spreadsheet in the cell where the formula is. On the Formula tab, click on Evaluate Formula, then keep clicking Evaluate until it gets to the answer and you can see what it is doing.

But basically, it's finding the position of the first number, then making an array of 1 to 15 character strings. It adds 0 to try and coerce each of these values to a number. LOOKUP(9.99999999E+307 will find the last number in this array while ignoring errors and this is your number.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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