forginganewone

Board Regular
Joined
Mar 14, 2018
Messages
64
Example cell values :
Demo-PAT-DIRBS-05513-C
Demo-PAC-Center-WirelessService-52515
Demo-PAT-SectorSplit-05096-OneCell-C

<tbody>
</tbody>

<tbody>
</tbody>

<tbody>
</tbody>

<tbody>
</tbody>

I want a formula which will extract only numbers from a cell but it should start counting numbers after 0.
For example : from this Demo-PAT-DIRBS-05513-C , it should extract 5513.

I tried using below formulas :

=RIGHT($C4,LEN($C4)-(SUM((MIN(IF(ISNUMBER(FIND({1,2,3,4,5,6,7,8,9},$C4)),FIND({1,2,3,4,5,6,7,8,9},$C4)))-1))))
^ this failed because in some cells the number value was in mid.

{=SUMPRODUCT(MID(0&C2,LARGE(INDEX(ISNUMBER(--MID(C2,ROW($1:$999),1))* ROW($1:$999),0),ROW($1:$999))+1,1)*10^ROW($1:$999)/10)}
^ this is giving #Num Error
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try:

=MID($C4,MATCH(TRUE,ISNUMBER(--MID($C4,ROW(INDIRECT("1:"&LEN($C4))),1)),0),5)

C+S+E
 
Upvote 0
also you can try PowerQuery

srcNumber
Demo-PAT-DIRBS-05513-C
5513​
Demo-PAC-Center-WirelessService-52515
52515​
Demo-PAT-SectorSplit-05096-OneCell-C
5096​

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    C2R = Table.AddColumn(Source, "Number", each Text.Trim([src],{"a".."z","A".."Z","-"})),
    Result = Table.TransformColumnTypes(C2R,{{"Number", Int64.Type}})
in
    Result[/SIZE]
 
Upvote 0
If all of the numbers in your text are 5 digits long like in your 3 examples, then this normally-entered formula should work for you...
Code:
[table="width: 500"]
[tr]
	[td]=0+MID(C4,MIN(FIND({0,1,2,3,4,5,6,7,8,9},C4&"0123456789")),5)[/td]
[/tr]
[/table]
If, on the other hand, your numbers can be of any length, then use this still normally-entered formula instead...
Code:
[table="width: 500"]
[tr]
	[td]=LOOKUP(9E+307,--LEFT(MID(C4,MIN(FIND({0,1,2,3,4,5,6,7,8,9},C4&"0123456789")),ROW($1:$99)),ROW($1:$99)))[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
Hi,

I want a formula which will extract only numbers from a cell but it should start counting numbers after 0.

Does that mean, as in your 2nd sample, if the number Does Not start with a 0 (zero), don't extract it?


Book1
CD
4Demo-PAT-DIRBS-05513-C5513
5Demo-PAC-Center-WirelessService-52515
6Demo-PAT-SectorSplit-05096-OneCell-C5096
Sheet439
Cell Formulas
RangeFormula
D4=IFERROR(LEFT(SUBSTITUTE(MID(C4,FIND("-0",C4)+2,100),"-",REPT(" ",100)),100)+0,"")
 
Upvote 0
=LOOKUP(9E+307,--LEFT(MID(C4,MIN(FIND({0,1,2,3,4,5,6,7,8,9},C4&"0123456789")),ROW($1:$99)),ROW($1:$99)))

<tbody>
</tbody>
a little shorter:

=LOOKUP(9E+307,--MID(C4,MIN(FIND({0,1,2,3,4,5,6,7,8,9},C4&"0123456789")),ROW($1:$99)))
 
Upvote 0
OR a UDF

Code:
Function Num(ByVal txt As String) As String
Dim X As Long 'original by Rick Rothstein    'This sample by Jerry Beaucaire
    For X = 1 To Len(txt)
        If Mid(txt, X, 1) Like "*[!0-9]*" Then Mid(txt, X, 1) = Chr(1) ' Leave only numbers
    Next
Num = Replace(txt, Chr(1), "")
End Function
 
Upvote 0
a little shorter:

=LOOKUP(9E+307,--MID(C4,MIN(FIND({0,1,2,3,4,5,6,7,8,9},C4&"0123456789")),ROW($1:$99)))

Even shorter:

=-LOOKUP(1,-MID(C4,MIN(FIND({0,1,2,3,4}+{0;5},C4&1/17)),ROW($1:$99)))
 
Upvote 0
Borrowed this one from XOR LX here

Array entered.
Code:
=NPV(-0.9,IFERROR(--MID(C4,99-ROW($1:$99)+1,1),""))/10
 
Upvote 0

Forum statistics

Threads
1,217,297
Messages
6,135,701
Members
449,959
Latest member
choy96

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