Find and split numerical value from string

vpranitha

New Member
Joined
Jun 26, 2014
Messages
25
Hello,

I have 3 scenarios of strings like below

P(23) D(2) O(3)
Y(24) DOR(3) O(2)
YM(23) DOR1(3) O(3)

Goal is to create a formula to capture number in O for diff string examples!! and split and sum all numbers in a diff column .

Assistance is greatly appreciated.

Thank you
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Assuming they start in cell A1 and all have an (O), then =VALUE(MID(A1,FIND(" O(",A1)+3,LEN(A1)-FIND(" O(",A1)-3)) should do the trick.
 
Upvote 0
If you're just after the number following the 'o(', you could use:
=-RIGHT(A1,LEN(A1)-SEARCH("o(",A1))
To sum them (assuming they're in A1:A3), you could use:
=SUM(-RIGHT(A1:A3,LEN(A1:A3)-SEARCH("o(",A1:A3)))
as an array formula.
 
Upvote 0
Hi vPranitha,

Two options :-

1) Use below formula to extract required numbers in a separate column :-

=SUBSTITUTE(MID(A1,SEARCH("O(",A1)+2,15),")","")*1

and they you can sum these extracted numbers easily. (Formula assumes your data is there in column A, row 1 onwards)

2) Use "Find & Replace" Ctrl + H option of Excel:-

Make a copy of the column, if you wish. First find *O( and replace with blank and then find ) and replace with blank and then you can sum the remaining numbers easily.


Regards,
DILIPandey
 
Upvote 0
Thanks all the scenario for O should work. What I meant to ask was if a cell A1 had either of the above scenario then I need value of O in one column and sum of all three values p/y/ym+d/dor/dor1+o in another column.
 
Upvote 0
Hello,

I have 3 scenarios of strings like below

P(23) D(2) O(3)
Y(24) DOR(3) O(2)
YM(23) DOR1(3) O(3)

Goal is to create a formula to capture number in O for diff string examples!! and split and sum all numbers in a diff column .

Assistance is greatly appreciated.

Thank you

Don’t you have parts that end in „O”, for example(?):

MH(56) MO(44) O(35)

where all the formulas above fail.
 
Upvote 0
Giordano Bruno's formula from #2 do it:

=VALUE(MID(A1,FIND(" O(",A1)+3,LEN(A1)-FIND(" O(",A1)-3))
 
Upvote 0
vpranitha,

Perhaps....

Excel 2007
ABC
1P(23) D(2) O(3)328
2Y(24) DOR(3) O(2)229
3YM(23) DOR1(3) O(3)329
4MH(56) MO(44) O(35)35135
Sheet2
Cell Formulas
RangeFormula
B1=VALUE(MID(A1,FIND(" O(",A1)+3,LEN(A1)-FIND(" O(",A1)-3))
C1=SUM(MID(SUBSTITUTE(SUBSTITUTE(A1,"(",REPT(" ",99)),")",REPT(" ",99)),{99,297,495},99)+0)
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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