Arn has a need to exclude certain words when sorting a column. For instance, he is trying to exclude "The" when sorting a list of movie titles, so that "Alpha, Charlie, The Bravo" would sort as "Alpha, The Bravo, Charlie."
There is no built-in way to do this. The best solution is to set up an intermediate column for your data. This column can contain the modified movie titles, and you can sort by the contents of the column. For instance, if column A contains your original movie titles, you could fill column B with formulas, such as this:
=IF(LEFT(A1,4)="The ",MID(A1,5,LEN(A1)-4),A1)
This formula will strip the word "The" (with its trailing space) from the start of the line. If you want to add the word "The" at the end of the string, then you could modify the formula in the following manner:
=IF(LEFT(A1,4)="The ",MID(A1,5,50),A1) & ", The"
If you wanted to delete all instances of the word "the" without regard to where it appeared in the title, you could use the following instead:
=SUBSTITUTE(A1,"the ","")
Sorting, again, would be done by the results shown in column B. This will give the list in the desired order.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11976) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Ignoring Selected Words when Sorting.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!
When you sort your data, you should always check to see if the sort was done correctly. What if sorting messes up ...
Discover MoreOne way you can easily work with data in a worksheet is to sort it into whatever order you find most helpful. Excel ...
Discover MoreSorting by dates is easy, and you end up with a list that is in chronological order. However, things become a bit more ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2018-12-26 09:50:25
J. Woolley
@Chuck W. - Instead of PROPER, you night be interested in the Title function posted here:
http://excelribbon.tips.net/T010560_Making_PROPER_Skip_Certain_Words.html#comment-form-hd
2018-12-26 00:10:05
Chuck W.
I am using Excel 2016, but I believe this affects all versions.
I tried your formula for stripping the word "The" from the beginning of song titles and putting it at the end after a comma.
Your version adds the comma and the word "The" outside of the IF function, which add them for every entry.
I believe the following version gives the correct results:
=IF(LEFT(A1,4)="The ",MID(A1,5,50) & ", The",A1)
In my particular application, the raw title was in all caps and I wanted the end result to have the first letter of each word only capitalized. I ended up with:
=PROPER(IF(LEFT(A1,4)="THE ",MID(A1,5,50) & ", THE",A1))
2016-03-27 05:32:54
John Downes
This formula strips out leading "The ", "A " and "An " from a text string in Cell A1. I use it to sort my movie title database.
=IF(LEFT(A1,4)="The ",RIGHT(A1,LEN($A1)-4),(IF(LEFT(A1,2)="A ",RIGHT(A1,LEN(A1)-2),IF(LEFT(A1,3)="An ",RIGHT(A1,LEN(A1)-3),A1))))
2016-03-27 02:25:11
David
The first formula is given as:
=IF(LEFT(A1,4)="The ",MID(A1,5,50),A1) & ", The"
This will add 'The' at the end of the title, even if there is no initial 'The' in the original title. The formula should be:
=IF(LEFT(A1,4)="The ",MID(A1,5,50) & ", The", A1)
2016-03-26 13:05:15
James
And, of course, that new sort column could be hidden.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2021 Sharon Parq Associates, Inc.
Comments