Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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: Sorting while Ignoring Leading Characters.

Sorting while Ignoring Leading Characters

by Allen Wyatt
(last updated December 13, 2014)

2

Ritesh has a huge amount of data that he needs to process in Excel. Each line in a worksheet includes a part number, in column A, by which he needs to sort the records. The problem is that Ritesh cannot do a straight sort; the first four characters of the part numbers need to be ignored. Thus, the sorting actually needs to start with the fifth character of the part number.

The easiest way to handle this situation is to create a new column in Excel that consists entirely of the information you want to use in the sort. In this case, you could add a new, blank column to the right of column A, and then enter this formula in the first cell of the column (assumed to be cell B2):

=RIGHT(A2,LEN(A2)-4)

You'll notice that cell B2 now contains the part number, beginning with the fifth character. Copy this formula down as many cells as necessary, and then perform a standard sort based on the contents of column B. You end up with the records in the desired order. You can then either delete column B, or you can hide it if you may need it later but don't want it to show up.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9870) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Sorting while Ignoring Leading Characters.

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

Selecting Sentences

Need to select an entire sentence at once? You can do so by creating a short macro that does the task for you, or you can ...

Discover More

Understanding Picas

Word can understand many different measurement units. One common unit understood by Word is the pica, described in this tip.

Discover More

Adjusting Column Width from the Keyboard

It's easy to adjust the width of table columns using the mouse, but what if you don't want to use the mouse? Adjusting column ...

Discover More

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!

More ExcelTips (ribbon)

Sorting Dates and Times

One of the strong features of Excel is its ability to sort information in a worksheet. When it doesn't sort information as ...

Discover More

Sorting Data Containing Merged Cells

When formatting the layout of your worksheet, Excel allows you to easily merge adjacent cells together. This can cause havoc ...

Discover More

Sorting ZIP Codes

Sorting ZIP Codes can be painless, provided all the codes are formatted the same. Here's how to do the sorting if you have ...

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. 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 9 + 4?

2014-12-13 10:08:07

Jason Swartzlander

If using Excel 2013 you can also use the "Flash Fill" feature. In this example, you would simply type the text as you want it (without the first four characters) and the copy using the fill handle (lower right corner of B2). You then select Flash Fill from the Auto Fill Options box that pops up. You can also use the Flash Fill option from the Fill feature in the Editing box of the Home tab. Hard to explain, easy to use!


2014-12-13 08:30:02

Wim deGroot

Why not use
=MID(A2, 5, 100)
assuming the cells have max 100 characters?
Meaning: begin with the 5th character and give the rest of the string.


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.