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
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
It would only have "staff" in the result if there is not a space between "%" and "s". The solution I provided requires "% s". If adding the space is not desired, then change the formula to this:

Excel Formula:
=TEXTAFTER(TEXTBEFORE(A2,"staff"),"$")
 
Upvote 1
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
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
Maybe this:

Excel Formula:
=TEXTAFTER(TEXTBEFORE(A2," "),"$")
 
Upvote 0
Maybe this:

Excel Formula:
=TEXTAFTER(TEXTBEFORE(A2," "),"$")
Wow that was quick - looks good but still has the word staff in the answer - i.e. answer = 4.02% staff - can we get rid of the word staff as well?
 
Upvote 0
Maybe this option will work
VBA Code:
=TEXTAFTER(TEXTBEFORE(A2," "),"$")

Edit: Just realized this is the same answer @dreid1011 posted initially!
 
Upvote 0
It would only have "staff" in the result if there is not a space between "%" and "s". The solution I provided requires "% s". If adding the space is not desired, then change the formula to this:

Excel Formula:
=TEXTAFTER(TEXTBEFORE(A2,"staff"),"$")
Champion!! Thanks a million!
 
Upvote 0

Forum statistics

Threads
1,215,854
Messages
6,127,339
Members
449,377
Latest member
CastorPollux

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