Extract text between a character and first space left of that character.

gcefaloni

Board Regular
Joined
Mar 15, 2016
Messages
119
Hi,

The title says it all. I'm trying to extract the text between a character (character is "%") and the first space to the left of that "%" character. I figure it would need to include the left and find functions but I am having a hardtime figuring out how to put it all together.

Any help would be greatly appreciated.

Thanks!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
One way: =MID(A1,1+FIND("%",A1),FIND(" ",A1,FIND("%",A1))-FIND("%",A1)-1)

With your string in A1 (and fill down, if more strings). This pulls the text after the % until the first space after the %.
Or was it to be the other way around...the space preceding the %?
 
Last edited:
Upvote 0
With your text in cell A1 and assuming the percent sign is no more than 300 characters from the beginning of the text (change the 300's if could be more), give this formula a try...

=TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("%",A1)-1)," ",REPT(" ",300)),300))
 
Upvote 0
One way: =MID(A1,1+FIND("%",A1),FIND(" ",A1,FIND("%",A1))-FIND("%",A1)-1)

With your string in A1 (and fill down, if more strings). This pulls the text after the % until the first space after the %.
Or was it to be the other way around...the space preceding the %?

Yes it was the space preceding. But thanks a lot for proposing your solution. It was very appreciated.
 
Upvote 0
With your text in cell A1 and assuming the percent sign is no more than 300 characters from the beginning of the text (change the 300's if could be more), give this formula a try...

=TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("%",A1)-1)," ",REPT(" ",300)),300))

Works like a charm.. Thank you so much!
 
Upvote 0
Try this formula
Code:
=LEFT(REPLACE(A1,1,SEARCH(" *%",A1),""),SEARCH("%",REPLACE(A1,1,SEARCH(" *%",A1),""))-1)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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