Stripping out certain words from start of cells

qetzel

New Member
Joined
Dec 17, 2013
Messages
10
Hi
I'm new to this forum, and hope someone might be able to help me. I have a range of about 5000 rows, each representing a title of an article, and I need to be able to strip out the words "The ", "Les", "A ", "Le ", "La " or "An " if they are at the start of each title.

So e.g. I start with:
The man in the moon
Les Miserables
Rage over October
A slight affair

and I finish with:
man in the moon
miserables
rage over October
slight affair

I've faffed around with mids and finds and substitutes but am running into problems because the strings I want to replace are all of different length. I'd be very grateful for any help, ideally which doesn't involve macros.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the board. Based on your sample data, the below should work:
=IF(ISNUMBER(MATCH(LEFT(A1,FIND(" ",A1)-1),{"The","Les","A","Le","La","An"},0)),RIGHT(A1,LEN(A1)-FIND(" ",A1)),A1)
 
Upvote 0
Welcome to the board. Based on your sample data, the below should work:
=IF(ISNUMBER(MATCH(LEFT(A1,FIND(" ",A1)-1),{"The","Les","A","Le","La","An"},0)),RIGHT(A1,LEN(A1)-FIND(" ",A1)),A1)

Dear Neil, That's absolutely fantastic! I've spent all day trying to solve this. Thank you so much :)
 
Upvote 0
Dear Neil, That's absolutely fantastic! I've spent all day trying to solve this. Thank you so much :)

Actually this is a bit of a cheek on my part, but the icing on the cake would be if the final result was just the one word, i.e:
start with:
The man in the moon
Les Miserables
Rage over October
A slight affair

and I finish with:
man
miserables
rage
slight

(the whole object of the exercise is so I can go on and create meaningful filenames with these words).
Sorry - should have posted the whole problem straight up.
Thanks again
 
Upvote 0
Actually this is a bit of a cheek on my part, but the icing on the cake would be if the final result was just the one word, i.e:
start with:
The man in the moon
Les Miserables
Rage over October
A slight affair

and I finish with:
man
miserables
rage
slight

(the whole object of the exercise is so I can go on and create meaningful filenames with these words).
Sorry - should have posted the whole problem straight up.
Thanks again

It's doable, but it's getting quite messy and a UDF would be more efficient than native functions. But since you stipulated no VBA...

=LOWER(IF(ISNUMBER(MATCH(LEFT(A1,FIND(" ",A1)-1),{"The","Les","A","Le","La","An"},0)),IF(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))>1,MID(A1,FIND(" ",A1)+1,FIND("#",SUBSTITUTE(A1," ","#",2))-FIND(" ",A1)-1),RIGHT(A1,LEN(A1)-FIND(" ",A1))),LEFT(A1,FIND(" ",A1)-1)))
 
Upvote 0
Or, if you're using 2010 or later:

=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",161)),161*(IFERROR(AGGREGATE(15,6,SEARCH(" "&{"The","Les","A","Le","La","An"}&" "," "&A1&" "),1),0))+1,161))

Regards
 
Upvote 0
Or, if you're using 2010 or later:

=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",161)),161*(IFERROR(AGGREGATE(15,6,SEARCH(" "&{"The","Les","A","Le","La","An"}&" "," "&A1&" "),1),0))+1,161))

Regards

Hi Neil and XorLX, just want to say thank you both so much for your help. I have to go out tonight, but I'll try these out first thing tomorrow. Thanks again :)
 
Upvote 0
Hi Neil and XorLX, just want to say thank you both so much for your help. I have to go out tonight, but I'll try these out first thing tomorrow. Thanks again :)

Hi again, rushed in this morning. Both formulae are brill, but neither completely perfect (Neil's fell over if cell didn't start with one of the forbidden words, whereas Xorlx's fell over if a forbidden word cropped up halfway through a cell). Since I could work out how to solve Neil's with a simple IFERROR statement, I went with that one. But thanks again to you both and thanks for introducing me to the Aggregate function, XorLx.
Best


Steph
 
Upvote 0
Glad you got it working, but my formula should work regardless. The first IF statement tests the text before the first space. If this isn't equal to one of the forbidden words, it returns the first word.
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,655
Members
448,975
Latest member
sweeberry

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