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 Letters and Numbers.

Sorting Letters and Numbers

by Allen Wyatt
(last updated June 14, 2014)

4

Let's say that you have a worksheet in which a particular column contains entries such as F1, F2, F3, etc., all the way up to F149. If you need to sort the data in the worksheet based on the contents of this column, the results may disappoint you. Because the first character in each cell is a letter, Excel sorts the column as text.

The upshot is that the cells are sorted in the order F1, F10, F100, F101, F102, etc. In this arrangement, F2 doesn't show up until the sixty-second entry in the sorted list. The reason this happens is because the cells are treated as text. As text, all the cells starting with F1 (there are 61 of them) come before the cells starting with F2.

The only way around this situation is to make sure that the numbers in the cells are front-padded with zeros. In other words, you shouldn't use F1, but F001. You can use the following formula to convert the old format numbers to the new format:

=LEFT(C1,1) & RIGHT("000" & RIGHT(C1,LEN(C1)-1),3)

Now, when you sort by the newly formatted entries, you get the desired results: F001, F002, F003, etc.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9600) 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 Letters and Numbers.

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

Easy Value Hiding

Want a quick and easy way to hid the information in a cell? You can do it with a simple three-character custom format.

Discover More

Inserting from the Clip Art Gallery Doesn't Work

Ever insert a picture and it won't display in your document? It could be due to some of the display settings in Word. Here's ...

Discover More

Inserting a Bullet

Need to place a bullet in the middle of a sentence? There are a couple of easy ways you can do this, as described in this ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling 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

Moving Cell Borders when Sorting

Sort your data and you may be surprised at what Excel does to your formatting. (Some formatting may be moved in the sort and ...

Discover More

Too Many Formats when Sorting

Sorting is one of the basic operations done in a worksheet. If your sorting won't work and you instead get an error message, ...

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?

2015-07-14 16:39:59

Louis

Dear Michael & Ramon, many thanks for your assistance. Much appreciated.


2015-07-13 10:34:11

Ramon

Hi Louis. I got it to work out - altho' I'm trying to figure out the workings/construction of the formula. In the given formula, the "C1" is where the example commences i.e. the first F1 in the column. Also, dont allow any " " (spaces) in the formula.


2015-07-13 09:32:32

Michael Armstrong

C1 is the first cell containing an old-format number. Copying the formula column-wise will convert column C's cells to the sortable format.


2015-07-12 10:30:38

Louis

Dear Allen,
Thanks for providing this tip. Regrettably I cannot implement it. Can you please advise why you are using "C1" in the formula? Please advise how to use the cell address containing the record that must be sorted? Can you perhaps elaborate on the logic of the formula?
Thank you. Louis


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.