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

Ignoring Selected Words when Sorting

by Allen Wyatt
(last updated March 26, 2016)

3

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.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Including Text Box Text in Word Counts

If you use text boxes in the layout of your documents, you should know that any word counts you perform do not include any ...

Discover More

Converting to Automatic Endnotes

When you add endnotes to a document, they are automatically maintained and renumbered by Word, as necessary. If you get a ...

Discover More

Controlling Where a Full-page Border is Printed

When you add full-page borders to your document, you may be bothered to find out that one or more sides of the border don't ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Sorting Letters and Numbers

Sorting information in a worksheet can be confusing when Excel applies sorting rules of which you are unaware. This is ...

Discover More

Separating Cells Based on Text Color

If the font color used for the data in your worksheet is critical, you may at sometime want to move cells that use a ...

Discover More

Can't Sort Imported Data

Import information from an external database, and you'll no doubt want to use Excel's simple tools to manipulate that data. ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 3 + 8?

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.


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.