Percentage from cell containing numbers and text

AWatson

New Member
Joined
Jun 29, 2008
Messages
12
Hi,

Is it possible to calculate a percentage from a cell that contains two numbers and text within the same cell? And is this possible without separating the numbers into separate cells?

E.g. If A1 contained the value "4 (19)", is it possible to create a formula to use the cell contents to calculate a percentage of 21% i.e. 4 of 19?

Similarly, if B1 contained the value "10 (20)", to calculate this as 50% (formula result in B2)?

The second number will always be in brackets.

Many thanks,
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
49,075
Office Version
  1. 365
Platform
  1. Windows
Try this.

Excel Workbook
AB
14 (19)21.05%
210 (20)50.00%
3
Percentage
 

chrisdavis

New Member
Joined
Jun 25, 2010
Messages
20
=LEFT(A1,FIND(" ",A1))/-MID(A1,FIND("(",A1),FIND(")",A1))

The first part takes the number left of the space and the next part looks at the number in the parenthesis. The second part required a minus sign because excel reads the number as a negative.
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
49,075
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

=LEFT(A1,FIND(" ",A1))/-MID(A1,FIND("(",A1),FIND(")",A1))

The first part takes the number left of the space and the next part looks at the number in the parenthesis. The second part required a minus sign because excel reads the number as a negative.
Chris

It may not be possible with the OP's data but the blue part would cause an error with your formula if there is a negative in the parentheses. For example try:
4 (-19)
 

AWatson

New Member
Joined
Jun 29, 2008
Messages
12
The formula in the first reply works perfectly. Thanks very much for your help.

Is there a way to deal with errors e.g. if the both numeric values in A1 are zeros i.e. "0 (0)" and the result is #DIV/0! or if the cell is blank with data yet to be entered and the result is #VALUE!
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
49,075
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Is there a way to deal with errors e.g. if the both numeric values in A1 are zeros i.e. "0 (0)" and the result is #DIV/0! or if the cell is blank with data yet to be entered and the result is #VALUE!
try this:

=IF(OR(A1="",COUNTIF(A1,"*(0)*")),"",LEFT(A1,FIND(" ",A1)-1)/SUBSTITUTE(REPLACE(A1,1,FIND("(",A1),""),")",""))
 

AWatson

New Member
Joined
Jun 29, 2008
Messages
12
That's brilliant - thanks again for your help. I would never have managed that on my own!!
 

chrisdavis

New Member
Joined
Jun 25, 2010
Messages
20
Chris

It may not be possible with the OP's data but the blue part would cause an error with your formula if there is a negative in the parentheses. For example try:
4 (-19)

Very good point...I did not consider the effects of a negative number. Thanks for pointing that out.
 

Watch MrExcel Video

Forum statistics

Threads
1,132,742
Messages
5,655,034
Members
418,171
Latest member
ramiroayala

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
Top