Excel: Sorting Data
Excel Sorting Data

As you add more content to a worksheet, organizing this information becomes especially important. You can quickly reorganize a worksheet by sorting your data. For example, you can organize a list of contact information by last name. Content can be sorted alphabetically, numerically, and in several other ways.

Watch the video below to learn more about sorting data in Excel.

Types of sorting

When sorting data, it's important to first decide if you want the sort to apply to the entire worksheet or just a cell range.

  • Sort sheet: Organizes all of the data in your worksheet by one column. Related information across each row is kept together when the sort is applied. In the example below, the Contact Name column (column A) has been sorted to display the names in alphabetical order.
  • A sorted worksheet
  • Sort range: Sorts the data in a range of cells, which can be helpful when working with a sheet that contains several tables. Sorting a range will not affect other content in the worksheet.
  • Sorting a range

To sort a sheet:

In our example, we'll sort a T-shirt order form alphabetically by Last Name (column C).

  1. Select a cell in the column you want to sort. In our example, we'll select cell C2.
  2. selecting cell C2
  3. Select the Data tab on the Ribbon, then click the A-Z command to sort A to Z, or the Z-A command to sort Z to A. In our example, we'll sort A to Z.
  4. sorting A to Z
  5. The worksheet will be sorted by the selected column. In our example, the worksheet is now sorted by last name.
  6. a spreadsheet sorted by last name

To sort a range:

In our example, we'll select a separate table in our T-shirt order form to sort the number of shirts that were ordered in each grade.

  1. Select the cell range you want to sort. In our example, we'll select cell range G2:H6.
  2. Selecting cells
  3. Select the Data tab on the Ribbon, then click the Sort command.
  4. The Sort button on the Data tab
  5. The Sort dialog box will appear. Choose the column you want to sort. In our example, we want to sort the data by the number of T-shirt orders, so we'll select Orders.
  6. The Sort dialog box
  7. Decide the sorting order (either ascending or descending). In our example, we'll use Largest to Smallest.
  8. Once you're satisfied with your selection, click OK.
  9. The Sort dialog box
  10. The cell range will be sorted by the selected column. In our example, the Orders column will be sorted from highest to lowest. Notice that the other content in the worksheet was not affected by the sort.
  11. The range has been sorted
If your data isn't sorting properly, double-check your cell values to make sure they are entered into the worksheet correctly. Even a small typo could cause problems when sorting a large worksheet.
A typo can ruin a sort

Custom sorting

Sometimes you may find that the default sorting options can't sort data in the order you need. Fortunately, Excel allows you to create a custom list to define your own sorting order.

To create a custom sort:

In our example, we want to sort the worksheet by T-Shirt Size (column D). A regular sort would organize the sizes alphabetically, which would be incorrect. Instead, we'll create a custom list to sort from smallest to largest.

  1. Select a cell in the column you want to sort. In our example, we'll select cell D2.
  2. Selecting cells
  3. Select the Data tab, then click the Sort command.
  4. The Sort dialog box
  5. The Sort dialog box will appear. Select the column you want to sort, then choose Custom List... from the Order field. In our example, we will choose to sort by T-Shirt Size.
  6. The Sort dialog box
  7. The Custom Lists dialog box will appear. Select NEW LIST from the Custom Lists: box.
  8. Type the items in the desired custom order in the List entries: box. In our example, we want to sort our data by T-shirt size from smallest to largest, so we'll type Small, Medium, Large, and X-Large, pressing Enter on the keyboard after each item.
  9. The Custom Lists dialog box
  10. Click Add to save the new sort order. The new list will be added to the Custom lists: box. Make sure the new list is selected, then click OK.
  11. The sheet has now been sorted with our custom criteria
  12. The Custom Lists dialog box will close. Click OK in the Sort dialog box to perform the custom sort.
  13. The sheet has now been sorted with our custom criteria
  14. The worksheet will be sorted by the custom order. In our example, the worksheet is now organized by T-shirt size from smallest to largest.
  15. The sheet has now been sorted with our custom criteria

Sorting levels

If you need more control over how your data is sorted, you can add multiple levels to any sort. This allows you to sort your data by more than one column.

To add a level:

In our example below, we'll sort the worksheet by T-Shirt Size (Column D), then by Homeroom # (column A).

  1. Select a cell in the column you want to sort. In our example, we'll select cell A2.
  2. The Sort dialog box adding level
  3. Click the Data tab, then select the Sort command.
  4. The Sort dialog box adding level
  5. The Sort dialog box will appear. Select the first column you want to sort. In this example, we will sort by T-Shirt Size (column D) with the custom list we previously created for the Order field.
  6. Click Add Level to add another column to sort.
  7. The Sort dialog box adding level
  8. Select the next column you want to sort, then click OK. In our example, we'll sort by Homeroom # (column A).
  9. The Sort dialog box with two levels
  10. The worksheet will be sorted according to the selected order. In our example, the orders are sorted by T-shirt size. Within each group of T-shirt sizes, students are sorted by homeroom number.
  11. The multi-level sort is applied to the worksheet
If you need to change the order of a multilevel sort, it's easy to control which column is sorted first. Simply select the desired column, then click the Move Up or Move Down arrow to adjust its priority.
Move levels up or down

Challenge!

  • Open our practice workbook.
  • Click the Challenge tab in the bottom-left of the workbook.
  • For the main table, create a custom sort that sorts by Grade from Smallest to Largest and then by Camper Name from A to Z.
  • Create a sort for the Additional Information section. Sort by Counselor (Column H) from A to Z.
  • When you're finished, your workbook should look like this:
Sorting Challenge Result

FAQs

What is the difference between Sort Sheet and Sort Range?

Sort Sheet reorganizes the entire worksheet based on one column, ensuring rows stay intact. Sort Range only sorts the specifically selected cells, leaving the rest of the worksheet unchanged.

How do I sort by color in Excel?

Open the Sort dialog box, and under "Sort On," select Cell Color or Font Color. You can then choose which color appears on top or bottom.

Why didn't my header row stay at the top when sorting?

In the Sort dialog box, ensure the checkbox "My data has headers" is checked. This tells Excel to exclude the first row from the sorting process.

Can I undo a sort if I made a mistake?

Yes, you can press Ctrl+Z immediately after sorting to undo it. However, if you have saved and closed the file, the sort cannot be undone unless you have a backup.

How many levels can I add to a sort?

You can add up to 64 levels of sorting criteria in the Sort dialog box, allowing for very detailed organization of data.

You May Also Like

Loading...