Excel Sort by Name and Rank: 2 Easy Methods

Formulas & functions · Updated November 23, 2026

To sort by name and then by rank in Excel, use the Sort dialog box (Data > Sort) and add two levels: first sort by the name column, then by the rank column. Alternatively, use the SORTBY function with two criteria for a formula-based approach that updates automatically.

Why Sorting by Two Columns Matters

When you have a list of people or items with both a name and a rank, sorting by only one column rarely gives you the order you want. For example, if you sort by rank only, names appear in random alphabetical order within the same rank. Sorting by name first groups all entries for each person together, and then sorting by rank orders those groups internally. This is common in leaderboards, employee directories, student rosters, or inventory lists where each name may have multiple entries (e.g., different products or dates).

Method 1: Using the Sort Dialog Box (Quickest)

This is the classic way and works in all Excel versions.

  1. Select any cell inside your data range (do not select only the column headers if you have multiple columns).
  2. Go to the Data tab on the ribbon.
  3. Click Sort (the icon with an A-Z and a downward arrow).
  4. In the Sort dialog, under Column, choose the column that contains the names (e.g., “Name”). Under Sort On, keep “Cell Values”. Under Order, choose A to Z (or Z to A if you prefer).
  5. Click Add Level.
  6. In the new row, choose the column that contains the ranks (e.g., “Rank”). Choose the order: Smallest to Largest for numeric ranks (1, 2, 3…) or A to Z if ranks are text (e.g., “Gold”, “Silver”).
  7. Click OK.

Your data will now be sorted by name first, and within each name, by rank. If you want rank first and then name, simply reorder the levels by selecting a row and using the up/down arrows in the dialog.

Method 2: Using the SORTBY Function (Dynamic)

If you want the sorted list to update automatically when you change the original data, use the SORTBY function. This requires Excel 365 or Excel 2021.

Assume your data is in A1:B10, with headers in row 1, names in A2:A10, and ranks in B2:B10. In a new area, say D2, enter:

=SORTBY(A2:B10, A2:A10, 1, B2:B10, 1)

This returns the entire range A2:B10 sorted first by column A (names) in ascending order (1), then by column B (ranks) in ascending order. The result spills into D2:E10 automatically. If you want descending rank order, change the last 1 to -1.

Sorting by Rank as Text vs. Number

A common pitfall is ranks stored as text, like “1st”, “2nd”, or “Gold”, “Silver”, “Bronze”. Excel sorts text alphabetically, so “10” comes before “2” if the rank column is stored as text. To fix this, convert text ranks to numbers before sorting. For numeric ranks, ensure the cells are formatted as numbers (Home > Number Format > General or Number). For text ranks like “Gold”, you can create a helper column with a numeric order (e.g., 1 for Gold, 2 for Silver) and sort by that helper column instead.

Common Problems and Fixes

  • Sorting only one column: If you select only one column before sorting, Excel warns you and may sort just that column, mixing up your rows. Always select the entire data range or click inside it before sorting.
  • Header row gets sorted: In the Sort dialog, check the “My data has headers” checkbox. If you don’t, the header row will be treated as data and sorted into the list.
  • Blank cells: Rows with blank names or ranks will be placed at the bottom by default. If you want them elsewhere, you can filter them out first.
  • Formula errors after sorting: If you use SORTBY, the result is a dynamic array that recalculates automatically. If you use the Sort dialog, any formulas in the original data will recalculate normally, but if you have references to specific cells, sorting will change those references.

Sorting on Mac and Excel for the Web

On a Mac, the Sort dialog is accessed via Data > Sort as well. The SORTBY function works identically in Excel for Microsoft 365 on Mac. On Excel for the web, the Sort dialog is also available under Data > Sort, and SORTBY works if you have a Microsoft 365 subscription. The keyboard shortcut for opening the Sort dialog on Windows is Alt + D + S (press sequentially). On Mac, there is no direct default shortcut, but you can use Command + Shift + L to toggle filters, then use the dropdown arrows to sort, or use the menu.

Frequently Asked Questions

How do I sort by last name when the full name is in one column?

If you have “John Smith” in one cell, you need to split it first. Use Text to Columns (Data > Text to Columns) with space as the delimiter, or use a formula to extract the last name: =RIGHT(A2, LEN(A2)-FIND(" ", A2)) (assuming a single space). Then sort by that helper column. For names with multiple spaces, you may need more complex formulas or the new TEXTSPLIT function in Microsoft 365.

Can I sort by name and rank at the same time using one click?

No, Excel’s single-click sort (A-Z or Z-A on the ribbon) only sorts by the column you selected. You must use the Sort dialog to add multiple levels, or use the SORTBY function for a dynamic multi-level sort.

Why does my rank sort as 1, 10, 2 instead of 1, 2, 10?

This happens when the rank column is stored as text. Select the column, go to Data > Text to Columns, and click Finish (with Delimited selected) to convert text numbers to real numbers. Alternatively, multiply by 1 using a helper column: =B2*1 and sort by that.

Does sorting affect my formulas or charts?

Sorting rearranges rows, so any formulas that reference specific cells will return values from the new rows. Charts based on the data will update to reflect the new order. If you need to preserve original order, copy the data to a new sheet before sorting.

How do I sort by rank first, then name?

In the Sort dialog, put the Rank level first and the Name level second. In SORTBY, list the rank range first: =SORTBY(A2:B10, B2:B10, 1, A2:A10, 1).

Is there a way to sort without changing the original data?

Yes, use the SORTBY function to create a sorted copy in a new location. The original data remains untouched, and the sorted list updates automatically if you change the source data.

Final Tips for Clean Sorted Data

Always make a backup copy of your workbook before sorting, especially if you have formulas or complex data. Use Excel Tables (Ctrl+T) to make sorting easier, as tables automatically expand and keep formatting. If you need to sort by multiple criteria frequently, consider creating a custom list (File > Options > Advanced > Edit Custom Lists) for non-standard orders like rank categories (e.g., Gold, Silver, Bronze).

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.