To sort rows in Excel by a column value, click a cell in the data, then choose Data > Sort A to Z or Data > Sort Z to A for a quick sort. For multiple sort rules or a specific order, choose Data > Sort, select the column and order, and make sure the whole data range is included so each row stays together.
What sorting does to your data
Sorting changes the order of rows according to values in one or more columns. For example, sorting a list of orders by delivery date puts the earliest or latest dates first. The values in the other columns move with each row, preserving the relationship between an order number, customer, date, and amount.
A sort is not the same as filtering. Sorting rearranges records; filtering temporarily hides records that do not meet a condition. You can sort a filtered list, but the hidden records remain part of the data and may become visible when you clear the filter.
The most important safety check is to sort complete records, not one column by itself. If customer names are sorted without their corresponding order numbers and dates, the data can become mismatched. Excel often detects adjacent data and offers to expand the selection, but verify the choice rather than assuming it has selected everything.
Sort a range by one column
For a basic ascending or descending sort in Excel for Microsoft 365 on Windows:
- Click any cell inside the contiguous data range. If the range has blank rows or columns splitting it, select the full range manually.
- Open the Data tab.
- In the Sort & Filter group, select Sort A to Z or Sort Z to A. Excel sorts text alphabetically, numbers numerically, and dates chronologically.
If Excel asks whether to expand the selection, choose Expand the selection to move the entire rows of data together. Choose Continue with the current selection only when you intentionally want to sort those selected cells independently, which is unusual for a table of records.
For more control, select Data > Sort. In the Sort dialog, set Sort by to the column, choose the relevant cell value or formatting option under Sort On, and choose an order. Select My data has headers when the first row contains column names; otherwise Excel may treat those labels as data. Select OK to apply the sort.
On Excel for Mac, the sorting controls are also on the Data tab, with the Sort command available from the ribbon. The precise ribbon layout can vary by window size and Excel build. Excel for the web also provides sort commands on the Data tab, though dialog options and layout can differ from the Windows desktop version.
Sort by more than one column
Use a multi-level sort when one column is not enough to define the desired order. Suppose a roster has Department, Last Name, and First Name columns. Sorting only by Department groups people by department but leaves the order within each group unspecified. A second level can arrange last names within each department, and a third can arrange first names when last names match.
- Click a cell in the data and choose Data > Sort.
- Set the first Sort by column and its order.
- Choose Add Level to add another rule, then select the next column and order.
- Continue adding levels as needed, checking that the first rule represents the main grouping.
- Confirm the header setting and select OK.
Excel applies the primary rule first and uses subsequent levels to order records that tie on earlier rules. For example, sort first by Department A to Z, then Last Name A to Z, then First Name A to Z. If your real priority is last name across the entire roster, make Last Name the first level instead.
The Sort dialog also supports sorting by cell color, font color, or conditional-formatting icon when those options are available for the data. This can help bring highlighted records to the top, but color is not a substitute for a clearly defined status field: a text value such as “Needs review” is easier to audit and maintain.
Choose the right order for text, numbers, and dates
For text, A to Z is ascending and Z to A is descending. Excel’s order is based on its sorting rules, not necessarily on how a person would group categories. For instance, a custom category sequence such as Urgent, Normal, Low is not alphabetical. In the Sort dialog, the Order menu can use a custom list where supported, or you can add a helper column containing numeric priorities and sort by that column.
Numbers sort from smallest to largest or largest to smallest. A value that looks like a number but is stored as text may sort differently from a real number. If entries such as 2, 10, and 100 appear in an unexpected sequence, check whether some cells are text. You can use Excel’s error indicators or inspect the values and number formats, then convert the data consistently before sorting.
Dates sort from oldest to newest or newest to oldest when Excel recognizes them as dates. Text that merely looks like a date may not sort chronologically. Mixed date formats, imported data, or a column containing both dates and explanatory text can cause confusing results. If a date column is inconsistent, clean or convert it before relying on the sort order.
Blank cells are generally placed after populated cells in ascending sorts and before them in descending sorts. If the position of blanks matters, fill them with a consistent value or use a helper column to specify the exact priority. Avoid inserting a made-up date or number into the original data unless it is clearly identified and appropriate for the dataset.
Keep headers and related rows together
A header row should remain at the top, not be sorted into the records. In the Sort dialog, check My data has headers. If the header is not detected correctly, select the data range including the header and set that option yourself. For a quick sort, clicking a cell in a clearly structured range usually lets Excel recognize the headers, but the dialog gives you a chance to confirm.
Converting a range to an Excel table can make repeated sorting easier. Select a cell in the data and choose Home > Format as Table, then confirm the range and whether it has headers. Tables add filter and sort dropdowns to their header cells and expand as you add adjacent records. A table does not eliminate the need to check what is included, especially if the worksheet contains nearby unrelated information.
When using a filter dropdown in a table or filtered range, open the dropdown on the column you want and choose the ascending or descending sort command. On Windows, Alt+Down Arrow opens the filter dropdown for the selected header cell in many Excel contexts. On Mac, keyboard shortcuts can differ by keyboard and Excel version, so the dropdown arrow or Data tab is a dependable alternative.
Use a formula for a separate sorted view
A normal sort changes the order of the source data. If you want a sorted result in another area while leaving the original list untouched, Microsoft 365 includes the dynamic-array SORT function. This is useful for a report or a view that should update as source values change, although it does not replace a properly structured source table.
With names in A2:A5 and sales amounts in B2:B5, enter this formula in D2 to return both columns sorted by the second column, from smallest to largest: =SORT(A2:B5,2,1). If the sales amounts are 240, 125, 310, and 180, the returned rows are ordered 125, 180, 240, 310, with each name remaining beside its sales amount. The formula sorts only the specified range; it does not include a header row in the result.
SORT is available in Microsoft 365 and Excel 2021 or later. The result spills into nearby cells, so leave enough empty space for the returned rows and columns. A blocked spill area produces an error until the obstructing cells are cleared. If you need a fixed one-time order, use the Data tab instead; if you need an automatically updating separate view, a formula may be more suitable.
Common sorting problems and how to fix them
- Only one column moved: undo immediately with Ctrl+Z on Windows or Command+Z on Mac, then select the complete range and sort again. If other edits have occurred since, undoing may affect those edits too.
- The header is mixed into the results: reopen Data > Sort and verify My data has headers. Also check that the selected range begins at the header row.
- Numbers or dates appear out of order: check for values stored as text, inconsistent formats, leading or trailing spaces, and mixed content in the same column. A cell’s displayed format alone does not guarantee that its underlying value has the intended type.
- Some records were left out: inspect the selected range for blank rows or columns that may have separated the data. Select the complete range explicitly, including every field that belongs to each record.
- Repeated values seem to change order: add another sort level to specify how ties should be arranged. Do not rely on the original order among equal values unless you have defined a secondary rule.
Before sorting a critical or shared workbook, consider saving a copy or confirming that the source data can be restored. Sorting can be undone in many ordinary cases, but undo history is not a durable backup and may be lost after closing the file or performing other operations.
Frequently Asked Questions
How do I sort a whole Excel sheet by one column?
Click a cell inside the data and use Data > Sort A to Z or Data > Sort Z to A. If Excel asks, choose Expand the selection so all columns in each record move together. For separated data, select the full range first.
How do I sort by a column without sorting the header?
Choose Data > Sort, select the column, and check My data has headers. This tells Excel to keep the first row as column labels rather than treating it as a record.
Can I sort Excel rows by two columns?
Yes. Open Data > Sort, set the primary column, select Add Level, and choose the secondary column. The second rule arranges rows that have the same value in the first column.
Why does Excel sort 10 before 2?
The values may be stored as text, in which case Excel can sort them alphabetically rather than numerically. Convert the entries to consistent numeric values, then sort again. Check for mixed text and numbers if only some entries behave unexpectedly.
Can Excel sort automatically when a value changes?
A regular Data tab sort does not continuously rearrange records whenever a value changes; run the sort again when needed. In Microsoft 365 or Excel 2021 and later, a separate view using SORT can recalculate as its source data changes, provided the formula’s range includes the relevant data.
Related
- Excel Max Row Count: How Many Rows Can a Sheet Hold?
- Excel Maximum Row Height: The 409-Point Limit
- Excel Max Date: What Is the Latest Date Excel Supports?
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Lowercase Names in Excel: Formula, Fill Down, and ReplaceTo lowercase names in Excel, use the LOWER function in a helper column, then fill the formula down.…
- Power Query Filter: How to Filter Rows in ExcelTo filter in Power Query, open the query in Power Query Editor, select the filter arrow in a…
- Excel IFS in Multiple Cells: Apply Logic Across RangesTo use IFS in multiple cells, write the formula for the first row, then copy or fill it…
- Basic IF Examples in Excel: How to Write the FormulaIn Excel, an IF formula checks whether a condition is true and returns one value if it is,…
- Unique Excel List Creation: Formulas, Tools, and TipsTo create a unique list in Microsoft Excel for Microsoft 365 on Windows, enter =UNIQUE(A2:A100) in an empty…
- Excel Conditional Formatting: Use a Formula for RulesYes. In Excel, conditional formatting can use a formula that evaluates to TRUE or FALSE to decide which…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.