Extract words strings with space before a specific word

myespooir

Board Regular
Joined
Jul 24, 2015
Messages
52
Hi there,

I’m trying to separate style and color.

My file has products like
ABC top in red
ACF bottoms in green
A C B top in blue

I need to extract ABC,ACF and A C B in these examples.

Can you help think of a formula that helps?

Thanks a lot!!
Chris
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
If the data to extract is always 3 characters, and it is OK to return the characters without spaces (i.e. ACB instead of A C B) :
=LEFT(SUBSTITUTE(A1," ",""),3)
 
Upvote 0
Give this array-entered** formula a try...

=LEFT(A1,MIN(IF(CODE(MID(A1,ROW(1:14),1))>96,ROW(1:14),9E+99))-1)

**Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself
 
Upvote 0
Give this array-entered** formula a try...

=LEFT(A1,MIN(IF(CODE(MID(A1,ROW(1:14),1))>96,ROW(1:14),9E+99))-1)

**Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself



The array returns the whole text string.

I want to extract the string before "top" or "Bottom". But this formula does not work either.
=TRIM(LEFT(C3,SEARCH(OR("Bottom","Top"),C3)-1))
 
Upvote 0
Thanks Jeff,

This formula works like magic!

A small problem, there is a third word, "Suit", in addition to "top" and "Bottom". the cells with text strings "Suit" are #VALUE .
I can make an if statement of your formula, to add suit in the mix, just wondering if you can a more straight forward way to do it?

like =iferror(LEFT(C3,(IFERROR(SEARCH("top",C3),SEARCH("bottom",C3))-2)),LEFT(C3,(IFERROR(SEARCH("suit",C3),"")-2)))
 
Last edited:
Upvote 0
The edited formula you have written works,
OR you can also use nested IF like :
=LEFT(C3,(IFERROR(SEARCH("top",C3),IFERROR(SEARCH("bottom",C3),SEARCH("suit",C3)))-2))
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,662
Members
449,462
Latest member
Chislobog

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