To sort in Excel and move entire rows together, select the full data range, then choose Data > Sort and set the column to sort by. If Excel asks whether to expand the selection, choose Expand the selection; that keeps each record’s values together as its row moves.
What it means to sort entire rows
A spreadsheet row often represents one record: for example, a customer, order, employee, or product. The information for that record is spread across columns, such as name, date, region, and amount. Sorting by one column changes the order of the records. To preserve the information, Excel must move the cells in each selected row as a unit, rather than rearranging only the values in the chosen column.
“Entire row” usually means the entire row of your data table, not every cell across the worksheet from column A to XFD. If your table uses columns A through F, sort the range containing those six columns. Any related information outside that selection will not move with it. This distinction matters when a worksheet has notes, calculations, or a second table beside the main list.
For example, suppose A2:C4 contains these records:
- Row 2: Maya Chen, West, 420
- Row 3: Luis Ortiz, East, 275
- Row 4: Asha Patel, Central, 610
Sorting the range A1:C4 by the amount column moves each name and region with its amount. Sorting only C2:C4 could instead leave the amounts beside the wrong people. That is the central rule: sort all columns that belong to the same records together.
The safest way to sort a range
In Excel for Microsoft 365 on Windows, use the Sort dialog when you want to be sure which range and column Excel will use. First check that your data has a single header row and that there are no blank rows or columns splitting the list. Then follow these steps:
- Select the complete data block, including its headers. Include every column that belongs to the records you want to keep together.
- Open Data > Sort.
- In the Sort dialog, check My data has headers if the first selected row contains column names. This prevents the header from being treated like an ordinary record.
- Under Sort by, choose the header for the column that should determine the order, such as Date, Region, or Amount.
- Choose the appropriate Sort On option, usually Cell Values, and select an order such as A to Z, Z to A, Smallest to Largest, or Oldest to Newest.
- Select OK and check several rows to confirm that the related values stayed together.
If you begin by selecting a cell or column inside a contiguous list rather than selecting the whole block, Excel may display a prompt asking whether to expand the selection. Choose Expand the selection to include neighboring columns in the sort. Choosing Continue with the current selection sorts only the selected cells and can break the relationship between columns. When the data is important, selecting the full range yourself is clearer than relying on Excel to guess its boundaries.
Sorting an Excel table
Formatting a list as an Excel table is a convenient way to reduce selection mistakes. Select a cell in the list and choose Home > Format as Table, then confirm the range and whether it has headers. You can also use Insert > Table. Once the data is a table, each header has a filter arrow. Choose the arrow in the column you want to sort, then select the relevant ascending or descending command. Excel sorts the table records, keeping the values in each row together.
Tables are particularly useful when the list grows. New rows added directly below a table are generally included as part of it, and table sorting works on the table’s data rather than on just one column. However, check that every column belonging to a record is inside the table. A comment or formula just outside the table will not automatically travel with a table row when you sort.
To remove a sort, use the same column’s filter arrow and choose the clear-sort option if it is available, or sort by a column that records the original order. Excel does not automatically remember the previous sequence as a separate backup. If the original order matters, add an ID or sequence column before sorting.
Using the Sort dialog for more control
The Sort dialog offers settings that are not always obvious from a header’s filter menu. Its Sort by field chooses the primary column. Sort On can sort by cell values, cell color, font color, or conditional-formatting icon when those options are applicable. The Order field controls the direction or sequence. For text, that may be A to Z or Z to A; for numbers, smallest to largest or largest to smallest.
Excel’s ordinary alphabetical order may not match a custom business sequence. If a status column should appear as Not Started, In Progress, and Complete, a standard A-to-Z sort will order the words alphabetically instead. In the Sort dialog, use the custom-list order option when it is available, or add a helper column containing a numeric rank and sort by that rank. A helper column makes the intended sequence explicit and is often easier for other people to understand.
For a sort that should treat rows from top to bottom as usual, leave the orientation at Sort top to bottom. The dialog also has an option to sort left to right, which sorts columns rather than records. That is useful for certain layouts but is not the right choice for a typical table of records.
Sorting by more than one column
A multi-level sort lets you group by one field and order records within each group by another. In the Sort dialog, set the first level, select Add Level, and choose the next column. Excel applies the first level before using the next level to order records that match on the first one.
For example, a staff list can be sorted first by Department, A to Z, and then by Last Name, A to Z. The result groups employees by department and alphabetizes names inside each group. A sales list could be sorted first by Region and then by Sales Amount, largest to smallest, to put the highest-value record at the top of each region.
Use the level controls to move a level up or down if you set the priority incorrectly. The order of levels matters: sorting by last name first and department second produces a different grouping from sorting by department first. Before confirming, review the list of levels in the dialog, especially when the workbook contains subtotals or other rows that should not be mixed into the data.
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 repeat the sort using the whole range. Do not save over the only copy before checking the result.
- The header was sorted into the records. Open Data > Sort and enable My data has headers. Also verify that the header row was included in the selected range.
- Some records did not move. Look for blank rows or columns, which can make Excel treat a list as separate blocks. Select the complete intended range explicitly, including any rows that should be part of the sort.
- Dates or numbers appear in an unexpected order. Some values may be stored as text, or a column may contain a mixture of text and numbers. Check the cell format and the underlying values; changing only the displayed format does not always convert text into a true date or number.
- Related notes stayed behind. The notes may be outside the selected range or outside the Excel table. Undo, expand the range to include them if they belong to each record, and sort again.
- The result looks right but later edits cause confusion. Add a stable ID column so each record can still be identified after its position changes. Row numbers are not permanent identifiers because sorting changes which record occupies each row.
Undo is most useful right after an incorrect sort. If later edits have been made, undoing several actions may also remove those edits. For a workbook where the original order is important, save a copy first or create an Original Order column with sequential values. That gives you a way to restore the earlier sequence by sorting on the saved values.
Sort commands, filters, and formula-based sorting
A filter and a sort are related but different. A filter hides records that do not meet a condition; a sort changes the order of records. In Excel, the filter arrows on a table or filtered range can do both. Filtering for one region does not delete the other records, and sorting the displayed list is not the same as moving a single row manually.
Excel also has a SORT worksheet function in Microsoft 365 and Excel 2021 or later. It returns a sorted result in another area rather than rearranging the source records in place. This can be useful for a live, sorted view while preserving the original order, but it is not a substitute for the Data tab sort when you need to physically reorder the source range. If you want to edit the original records in their new sequence, use the Sort command instead.
In Excel for Mac, the same basic approach applies: select the data and use the Data tab’s sort controls or the table header’s sort menu. Ribbon placement and dialog appearance can vary slightly by release. Excel for the web also supports sorting ranges and tables, though its interface may differ from the Windows desktop dialog. In every version, confirm the selected range and header treatment before applying a sort.
Frequently Asked Questions
How do I sort one column without messing up the other columns?
Sort the complete table or data range, not just the one column. Use Data > Sort, choose the column as the sort key, and include all columns that belong to each record. If Excel asks whether to expand the selection, choose Expand the selection.
Will sorting in Excel move the whole row?
It moves the cells across the selected range as a row when the full record range is included. It does not necessarily move unrelated cells elsewhere on the worksheet. Include every column whose values must stay associated with that record.
Can I sort a table without selecting all its rows?
Yes. Click a cell in an Excel table and use a header’s filter arrow to sort that table by the chosen column. Check that all relevant fields are within the table, especially if notes or calculations sit beside it.
How do I keep my original row order?
Before sorting, add a column with sequential values such as 1, 2, 3, and so on. You can later sort by that column to restore the saved order. Alternatively, save a separate copy of the workbook before making changes.
Why did Excel sort my dates or numbers incorrectly?
The affected values may be stored as text, or the column may mix text with real dates or numbers. Inspect a few cells and convert inconsistent entries to a consistent data type before sorting. A display format alone may not correct the underlying value.
Related
- Excel Weekday Text: Show Dates as Day Names
- Excel WEEKDAY: Return a Day Name from a Date
- Excel NOW as Text: Show the Current Date and Time
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- XLOOKUP Match Mode: Exact, Approximate, and WildcardsIn Excel, XLOOKUP’s match_mode is its fifth argument: use 0 for an exact match, -1 for an exact…
- Excel Formula for High and Low Values: MIN and MAXIn Excel, use =MIN(B2:B10) to find the lowest number in a range and =MAX(B2:B10) to find the highest.…
- Excel Not Equal Symbol: How to Use <> in FormulasIn Microsoft Excel, the not-equal operator is <>—a less-than sign followed by a greater-than sign. Use it in…
- Excel Formula Showing Instead of Result? Causes and FixesIf Excel is showing a formula instead of its result, first check whether Show Formulas is turned on;…
- Excel XLOOKUP Practice Examples: Formulas and TipsExcel XLOOKUP practice examples are easiest to learn by matching a lookup value to a column and returning…
- Excel ROUNDUP Examples: 10 Practical Ways to RoundExcel’s ROUNDUP function always rounds a number away from zero, which makes it useful when a decimal result…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.