Extracting certain numbers from a Cell

SAFMF

New Member
Joined
Sep 5, 2014
Messages
13
I am trying to extract the digits after the '-' in this type of data 236-1,46-2,jm007-6,893-2.

Any help would be appreciated.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
in some rare occasions there may a situation where the number may be a32,b3,c1. But there would never be any time when three digits follow the letter
 
Upvote 0
And following the discussion between some of us earlier in the thread ..
a32,b3,c1 has 3 "terms" (two commas)

Is there a maximum number of "terms" in a single cell or could a cell have this (or longer)?
a2,b4,c54,d3,e6,f5,x4,s3,a3,b56,g3
 
Upvote 0
you can try this amybe this is what you want.
Data is in B4 and formula is in H4.

=SUMPRODUCT(IFERROR(MID(B4,--(FREQUENCY(--(MID(B4,ROW(INDIRECT("1:"&LEN(B4))),1)="-")*ROW(INDIRECT("1:"&LEN(B4))),--(MID(B4,ROW(INDIRECT("1:"&LEN(B4))),1)<>"-")*ROW(INDIRECT("1:"&LEN(B4))))=1)*ROW(INDIRECT("1:"&LEN(B4)+1)),1)+0,0))
 
Upvote 0
you can try this amybe this is what you want.
Data is in B4 and formula is in H4.

=SUMPRODUCT(IFERROR(MID(B4,--(FREQUENCY(--(MID(B4,ROW(INDIRECT("1:"&LEN(B4))),1)="-")*ROW(INDIRECT("1:"&LEN(B4))),--(MID(B4,ROW(INDIRECT("1:"&LEN(B4))),1)<>"-")*ROW(INDIRECT("1:"&LEN(B4))))=1)*ROW(INDIRECT("1:"&LEN(B4)+1)),1)+0,0))

This formula returns a '0'. I have changed the B4 to be V2 as this is the first cell where my data is currently sitting.
 
Upvote 0
This formula returns a '0'. I have changed the B4 to be V2 as this is the first cell where my data is currently sitting.


If I change the second zero in this part +0,0)) to a 1 it returns 9 not thre as expected from the data it is looking at which in this example is g1,b1,a1

Any ideas?
 
Upvote 0
In the samle I have done on my part,(Text in B4 and Formula in H4), it is returning 11.

Always Ctrl + Shift + Enter
 
Upvote 0
Not beautiful but works

=SUM(IFERROR(--RIGHT(TRIM(MID(SUBSTITUTE($A2,",",REPT(" ",LEN($A2))),{0;1;2;3;4;5;6}*LEN($A2)+1,LEN($A2))),2),IFERROR(--RIGHT(TRIM(MID(SUBSTITUTE($A2,",",REPT(" ",LEN($A2))),{0;1;2;3;4;5;6}*LEN($A2)+1,LEN($A2)))),0)))

CTRL+SHIFT+ENTER
 
Upvote 0
Try this formula to handle the second series of samples (b1,f23,c2 etc.):

=SUM(IFERROR(1*REPLACE(TRIM(MID(SUBSTITUTE(","&A1&",",",",REPT(" ",50)),{1,2,3,4,5,6,7,8}*50,50)),1,1,""),0))
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,982
Members
449,201
Latest member
Lunzwe73

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