Excel.Tips.Net ExcelTips (Menu Interface)

Creating a Sort Order

Summary: Excel is very flexible in how it can sort your data. You can even create your own custom sort order that is helpful when trying to get non-sequential information sorted in a unique order. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Creating a Sort Order.)

There are times when a normal sorting order just doesn't cut it. Instead, you need a special sorting order that fits the type of data you are working with. In the previous tip you learned that you can instruct Excel to sort by a special sorting order, such as days of the week. You can also easily create your own sorting orders.

For instance, let's assume you have a field that can contain the name of one of four colors—Black, Red, Green, and Orange—and that you wanted your list sorted in that order. The problem is, Excel would normally sort this list alphabetically—Black, Green, Orange, and Red. The solution is to create a custom list that has the color names in the order you desire.

To create a custom list, follow these steps if you are using Excel 2007:

  1. Click the Office button and then click Excel Options. Excel displays the Excel Options dialog box.
  2. Make sure Popular is selected at the left of the dialog box.
  3. Click Edit Custom Lists. Excel displays the Custom Lists dialog box and hides the Excel Options dialog box. (Click here to see a related figure.)
  4. Select the NEW LIST option from the Custom Lists list at the left of the dialog box.
  5. In the List Entries portion of the dialog box, start typing the order in which you want the elements sorted.
  1. When you are done, click the Add button.
  2. Repeat steps 4 through 6 to define any other lists desired.
  3. Click OK to finish.

If you are using a version of Excel prior to Excel 2007 follow these steps instead:

  1. Select Options from the Tools menu. Excel displays the Options dialog box.
  2. Make sure the Custom Lists tab is selected. (Click here to see a related figure.)
  3. Select the NEW LIST option from the Custom Lists list.
  4. In the List Entries portion of the dialog box, start typing the order in which you want the elements sorted.
  1. When you are done, click the Add button.
  2. Repeat steps 3 through 5 to define any other lists desired.
  3. Click OK to finish.

In steps 5 or 4 (depending on your version of Excel) you need to enter information in the List Entries area of the dialog box. For this example you would type the following:

Black
Red
Green
Orange

Make sure you press Enter at the end of each element and that what you type matches exactly the possible contents of the sorting field. Once your lists are defined, you can use them to sort as described in other ExcelTips.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2920) applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003 | 2007

You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Creating a Sort Order.

Related Tips:

Your Data, Your Way! Want the greatest control possible over how your data appears on the page? Excel's custom formats can provide that control, and ExcelTips: Custom Formats can unlock the secrets to creating your own custom formats. Check out ExcelTips: Custom Formats today!