Extract First or Last N Characters from String in Excel

janema

Board Regular
Joined
Nov 28, 2022
Messages
143
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2011
  5. 2010
Platform
  1. Windows
  2. Mobile
I am trying to only pull the percentage of column F, but is there a way to ensure it only pulls NUMBERS with the percentage sign?

For example: in the image shown below, the last 4 numbers brings in text to, but it should only bring in the numbers in front of the percentage. The only problem is that the percentage amounts vary between "5%" to "125%" so I am not sure if there is a formula that can pull in the correct percentage without extra text, spaces ,or missing data. This is a tough one for me. PLEASE HELP.

1710283850486.png
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
In 365 you can use
Excel Formula:
=1*TextBefore(TextAfter(F75,"Target "),"%")

In other versions try:
Excel Formula:
=Right(Substitute(F75,"%",""),Len(F75)-Find("Target ",F75)-7)


Book1
FGH
75adskjf jkdlfjlkasjdlf Target 5%55
76adskjf jkdlfjlkasjdlf Target 75%7575
77adskjf jkdlfjlkasjdlf Target 125%125125
Sheet1
Cell Formulas
RangeFormula
G75:G77G75=1*RIGHT(SUBSTITUTE(F75,"%",""),LEN(F75)-FIND("Target ",F75)-7)
H75:H77H75=1*TEXTBEFORE(TEXTAFTER(F75,"Target "),"%")
 
Last edited:
Upvote 1
Solution
In 365 you can use
Excel Formula:
=1*TextBefore(TextAfter(F75,"Target "),"%")

In other versions try:
Excel Formula:
=Right(Substitute(F75,"%",""),Len(F75)-Find("Target ",F75)-7)


Book1
FGH
75adskjf jkdlfjlkasjdlf Target 5%55
76adskjf jkdlfjlkasjdlf Target 75%7575
77adskjf jkdlfjlkasjdlf Target 125%125125
Sheet1
Cell Formulas
RangeFormula
G75:G77G75=1*RIGHT(SUBSTITUTE(F75,"%",""),LEN(F75)-FIND("Target ",F75)-7)
H75:H77H75=1*TEXTBEFORE(TEXTAFTER(F75,"Target "),"%")

That worked!!! Thank you so much!
 
Upvote 0
Based on your sample data there are some considerably simpler formulas you could also use.

24 03 13.xlsm
FGH
74Earlier365
75adskjf jkdlfjlkasjdlf Target 5%55
76adskjf jkdlfjlkasjdlf Target 75%7575
77adskjf jkdlfjlkasjdlf Target 125%125125
Extract number
Cell Formulas
RangeFormula
G75:G77G75=RIGHT(SUBSTITUTE(F75," ",REPT(" ",20)),20)*100
H75:H77H75=TEXTAFTER(F75," ",-1)*100
 
Upvote 1
Based on your sample data there are some considerably simpler formulas you could also use.

24 03 13.xlsm
FGH
74Earlier365
75adskjf jkdlfjlkasjdlf Target 5%55
76adskjf jkdlfjlkasjdlf Target 75%7575
77adskjf jkdlfjlkasjdlf Target 125%125125
Extract number
Cell Formulas
RangeFormula
G75:G77G75=RIGHT(SUBSTITUTE(F75," ",REPT(" ",20)),20)*100
H75:H77H75=TEXTAFTER(F75," ",-1)*100
You could do the whole range with just a single formula (in 365)...
Excel Formula:
=TEXTAFTER(F75:F77," ",-1)*100
 
Upvote 1
That worked!!! Thank you so much!
Happy to help. And there are other formulas that have been suggested that work as well. I even learned a new way to use some functions with some of them.

Best Wishes!
 
Upvote 1

Forum statistics

Threads
1,223,911
Messages
6,175,325
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