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
 
Thanks for the explanation & glad you worked it out. However ..


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")
Yeah it's weird - the one in K just gives me "N/a" for everything.
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
the one in K just gives me "N/a" for everything.
Sorry, a couple of things happened there
  1. I forgot to change the cell references from column A to column H in my formula, and
  2. I forgot to allow for the fact that you seem to have a non-standard space character between the % sign and the word staff (I'm guessing CHAR(160))
To at least satisfy my curiosity could you try this one please?

24 01 31.xlsm
HK
1
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%
10N/a
Extract %
Cell Formulas
RangeFormula
K2:K10K2=IFERROR(--MID(H2,2,FIND("%",H2)-1),"N/a")
 
Upvote 0
Sorry, a couple of things happened there
  1. I forgot to change the cell references from column A to column H in my formula, and
  2. I forgot to allow for the fact that you seem to have a non-standard space character between the % sign and the word staff (I'm guessing CHAR(160))
To at least satisfy my curiosity could you try this one please?
I changed mine to divide by 100, so that it actually returned a percentage, but you don't need to use MID, Excel will recognize the number despite the $ sign

Since you're allowing for a non-breaking space ,perhaps:
=IFERROR(LEFT(H2,FIND("%",H2)-1)/100,"N/a")
 
Upvote 0
I changed mine to divide by 100, so that it actually returned a percentage, but you don't need to use MID, Excel will recognize the number despite the $ sign
Instead of excluding the % sign & recognising the number despite the $ sign then converting to a percentage by dividing by 100 I deliberately used mid to avoid the $ sign but include the % & coerced to a number with Excel then recognising it not only as a number but as a percentage.
Six of one and half a dozen of the other I guess. :)
 
Upvote 1
Sorry, a couple of things happened there
  1. I forgot to change the cell references from column A to column H in my formula, and
  2. I forgot to allow for the fact that you seem to have a non-standard space character between the % sign and the word staff (I'm guessing CHAR(160))
To at least satisfy my curiosity could you try this one please?

24 01 31.xlsm
HK
1
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%
10N/a
Extract %
Cell Formulas
RangeFormula
K2:K10K2=IFERROR(--MID(H2,2,FIND("%",H2)-1),"N/a")
Bingo!! Thanks for discussing with me. I will learn from your formula!!
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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