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

Getting Rid of Mail Merge Section Breaks

When you create a group of documents from a merge file, Word normally inserts section breaks between iterations of the ...

Discover More

Working with Fonts

Windows allows you to install different fonts that control how information is displayed and printed. This tip gives a ...

Discover More

Sizing Text Boxes and Cells the Same

Adding a text box to a worksheet is easy. Making sure that text box is the exact size of a cell in the worksheet may not be ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Sorting Dates by Month

Sorting by dates is easy, and you end up with a list that is in chronological order. However, things become a bit more tricky ...

Discover More

Controlling Sorting Order

When you sort information in a worksheet, you have control over the order in which that information is sorted. Here's a quick ...

Discover More

Sorting IP Addresses

If you keep track of IP addresses in an Excel worksheet, you probably already know that it is difficult to sort those ...

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 8Mpixels. 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 6 - 3?

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.