formula to extract numbers from text

Obewan

Board Regular
Joined
Aug 25, 2021
Messages
68
Office Version
  1. 365
Platform
  1. Windows
I want a formula to extract the % numbers from the text in column B - data below is from column A. Answer can just be a number or % format. For example answer for the first one would = 4.02%. Thanks in advance!!

Staff costs
$4.02% staff costs
$73.31% staff costs
$60.60% staff costs
$59.94% staff costs
$74.16% staff costs
$11.47% staff costs
$53.33% staff costs
$100.90% staff costs
 
Try this and format the column as % with 2 decimal places.

24 01 31.xlsm
AB
1Staff costs
2$4.02% staff costs4.02%
3$73.31% staff costs73.31%
4$60.60% staff costs60.60%
5$59.94% staff costs59.94%
6$74.16% staff costs74.16%
7$11.47% staff costs11.47%
8$53.33% staff costs53.33%
9$100.90% staff costs100.90%
Extract %
Cell Formulas
RangeFormula
B2:B9B2=--MID(A2,2,FIND("%",A2))
 
Upvote 1

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try this and format the column as % with 2 decimal places.

24 01 31.xlsm
AB
1Staff costs
2$4.02% staff costs4.02%
3$73.31% staff costs73.31%
4$60.60% staff costs60.60%
5$59.94% staff costs59.94%
6$74.16% staff costs74.16%
7$11.47% staff costs11.47%
8$53.33% staff costs53.33%
9$100.90% staff costs100.90%
Extract %
Cell Formulas
RangeFormula
B2:B9B2=--MID(A2,2,FIND("%",A2))
Thanks!!
Just wondering how you get that formula to give 4.02% for the first result?

How did you format the result cell?
yeah all good - thanks again!!
 
Upvote 0
yeah all good - thanks again!!
Sorry, that does not answer my question.
I interpreted your response in post 12 to mean that Scott's formula was the one that gave you the answer you wanted. I'm not saying that it doesn't, but I couldn't see how it did and was interested to find out about it.
 
Upvote 0
I actually worked it out myself using this =IFERROR(TEXTAFTER(TEXTBEFORE(H41,"staff"),"$"),"N/a")
 
Upvote 0
I actually worked it out myself using this =IFERROR(TEXTAFTER(TEXTBEFORE(H41,"staff"),"$"),"N/a")
Then I added this to extract the % and turn into a figure =TEXTBEFORE(N2,"%")/100
 
Upvote 0
Then I added this to extract the % and turn into a figure =TEXTBEFORE(N2,"%")/100
actually this works better - =IFERROR(TEXTAFTER(TEXTBEFORE(H2,"%"),"$"),"N/a")/100 the issue was the "%" was a text value
 
Upvote 0
Thanks for the explanation & glad you worked it out. However ..

actually this works better - =IFERROR(TEXTAFTER(TEXTBEFORE(H2,"%"),"$"),"N/a")/100 the issue was the "%" was a text value
I don't think so. I think you would need the IFEEROR around the whole lot, not just before the /100
The two versions shown in I:J below.
Also, what about the somewhat simpler version offered before, but now including the IFERROR, in col K below

24 01 31.xlsm
HIJK
1
2$4.02% staff costs4.02%4.02%4.02%
3$73.31% staff costs73.31%73.31%73.31%
4$60.60% staff costs60.60%60.60%60.60%
5$59.94% staff costs59.94%59.94%59.94%
6$74.16% staff costs74.16%74.16%74.16%
7$11.47% staff costs11.47%11.47%11.47%
8$53.33% staff costs53.33%53.33%53.33%
9$100.90% staff costs100.90%100.90%100.90%
10#VALUE!N/aN/a
Extract %
Cell Formulas
RangeFormula
I2:I10I2=IFERROR(TEXTAFTER(TEXTBEFORE(H2,"%"),"$"),"N/a")/100
J2:J10J2=IFERROR(TEXTAFTER(TEXTBEFORE(H2,"%"),"$")/100,"N/a")
K2:K10K2=IFERROR(--MID(A2,2,FIND("%",A2)),"N/a")
 
Last edited:
Upvote 0
Maybe better:
=SUBSTITUTE(A1,"% staff costs","")/100

Format as % with 2 decimal places

Book1
AB
1Staff Costs
2$4.02% staff costs4.02%
3$73.31% staff costs73.31%
4$60.60% staff costs60.60%
5$59.94% staff costs59.94%
6$74.16% staff costs74.16%
7$11.47% staff costs11.47%
8$53.33% staff costs53.33%
9$100.90% staff costs100.90%
Sheet1
Cell Formulas
RangeFormula
B2:B9B2=SUBSTITUTE(A2,"% staff costs","")/100
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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