Excel.Tips.Net ExcelTips (Menu Interface)

Sorting by Five Columns

Excel includes a sorting feature that allows you to easily sort a data list by up to three columns. If you have a large or complex data list, you may want to sort by more than three columns, however. There are several ways you can accomplish this.

Assuming you have five columns you want sorted by, the first method is to just do two passes at sorting. If you want to sort the data in the order of columns A, B, C, D, and E, you would perform the first sort using columns C, D, and E. Once these are in order, sort by columns A and B. The result is that your entire data list is in order.

Closely related to this is the fact that you can use the sort tools on the toolbar to sort your five columns. First, choose a cell in column E, then click on either the Sort Ascending or Sort Descending tool. Repeat this process by selecting a cell in each of the other columns (D, C, B, and A), in turn, and clicking on the appropriate tool. At the end of this iterative process (which takes only five quick clicks of the sorting tools), your entire list is in the order you desire.

There is an important things to keep in mind when sorting as described here: The character of your list data can affect the quality of the sort performed. If your data contains empty cells, error values, or numbers formatted as text, then Excel may not sort the data in the method you expect. The solution is to "normalize" your data—for instance, making sure that numbers are really numbers and not numbers formatted as text—and then do the sort again.

Another solution is to create a "sorting column" for your data. This approach works great if your data is all text, or if you can easily convert it into a text-based format for the sorting. Under this scenario, you would combine the contents of columns A through E into column F, and then sort by a single column: F. You could use this type of formula in column F:

=A1 & B1 & C1 & D1 & E1

If one of the columns contains a date, you will need to convert the date to a consistent text format, as done with this formula:

=A1 & B1 & C1 & TEXT(D1,"yyyymmdd") & E1

If one of the columns contains numeric values, you can normalize them by using a similar TEXT function construct that pads the value with leading zeroes:

=A1 & TEXT(B1,"000000") & C1 & D1 & E1

If you do quite a bit of sorting, and you don't want to use Excel's built-in sorting routines, then you should investigate third-party sorting functions. Sorting algorithms are a fascinating branch of mathematics, and some very popular algorithms (such as shell sort, exchange sort, bubble sort, etc.) can be implemented through Excel functions. How those functions would be used on your system depends on the way they were implemented by their developer.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2255) applies to Microsoft Excel 97, 2000, 2002, and 2003.

Related Tips:

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA 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:

Parth    24 May 2016, 07:37
Dear Sir,

I want to sort 6 columns with 50 rows each containing ticket no. (data is in number format). I need to sort these 300 data from top top bottom and left to right. How can I sort so that i get values in ascending order from cell A1 to A50 and continues to B1 and so on.

One thing I can do is to arrange all data in a single cell, sort it and then again break it into columns. But that is too much for me. Any other method to do it??

I need to do this so that I can print that data in a single sheet.
liaqat ali    18 Oct 2015, 07:50
how do we sort MS WORD & MS EXCELL
REPLY me fast

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.