Excel.Tips.Net ExcelTips (Menu Interface)

Ignoring Selected Words when Sorting

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Ignoring Selected Words when Sorting.

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 (3892) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Ignoring Selected Words when Sorting.

Related Tips:

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!


Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 5+3 (To prevent automated submissions and spam.)
           Commenting Terms

Comments for this tip:

Jesse    15 Jan 2016, 02:56
Your example formula:
=IF(LEFT(A1,4)="The ",MID(A1,5,50),A1) & ", The"
is actually incorrect. It removes "The" if it's there, but adds ", The" only if the original string did NOT start with 'The'.

Should be:
=IF(LEFT(A1,4)="The ",MID(A1,5,50) & ", The",A1)
Anthony E    05 Sep 2015, 11:47
Hey Jack!

 To your formula -- how do you do the same for the letter "A," and the word "An?"

I want to do it for all 3, except I am having an issue in excel. I think it is because of how many parenthesis I put in the formula. Is there anyone you can send me an entire "IF" FORMULA?

Bill    18 Apr 2015, 14:00
Perfect solution to my problem! Thank you!
Jack    04 Aug 2012, 05:03
This is an excellent tip. This is the full formula I used and then filled down:

=IF(LEFT(A2,4)="The ",MID(A2,5,LEN(A2)-4)&", The",A2)
Juan    03 Aug 2012, 15:44
It would be helpful if you include a particular example to apply the formula. Thanks!

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.