Sort Excel by Column for the Entire Worksheet

Formulas & functions · Updated November 18, 2026

To sort a column without separating its rows, click a cell in your data, choose Data > Sort, select the column and order, and make sure Excel sorts the entire data range. If Excel asks whether to expand the selection, choose Expand the selection; sorting only one column can mismatch values that belong together.

What “sort the entire worksheet” means

In most spreadsheets, a worksheet contains a table-like block of records: each row is one record, and each column holds a field such as a name, date, department, or amount. Sorting the worksheet by a column usually means rearranging those complete rows according to the values in that column. For example, sorting a list of orders by order date should move each order’s customer, amount, and status along with its date.

Excel does not normally need to sort every cell in the sheet. Instead, it sorts the connected data range containing the records. This distinction matters because a worksheet can have more than a million rows and many columns, while the actual table may use only a small portion of them. The goal is to include every related column in the sort, not unrelated notes or separate tables elsewhere on the sheet.

“Sort by column” can also mean sorting columns from left to right, rather than sorting rows from top to bottom. That is a different operation. The usual task—ordering records based on one field—uses the standard top-to-bottom sort. The left-to-right option is useful when each column is a period, category, or other item that should move as a unit.

Sort the full data range in Excel for Windows

In Excel for Microsoft 365 on Windows, use the Sort dialog when you want to check the selected range and specify exactly which field controls the order. Before sorting, confirm that the table has a clear header row and that each record occupies one row.

  1. Click a cell inside the data block. If the range has blank rows or columns that divide it, select the complete range manually, including all columns that belong to each record.
  2. Open Data > Sort & Filter > Sort. The Sort dialog lets you choose a sort column and order. In some ribbon layouts, the Sort command may appear without the group label.
  3. If the first row contains labels such as “Name” or “Date,” check My data has headers. This keeps the labels at the top rather than treating them as data.
  4. Under Column, select the field to sort by. Under Sort On, choose Cell Values for an ordinary text, number, or date sort.
  5. Under Order, choose the order you need, such as A to Z, Z to A, Smallest to Largest, Largest to Smallest, or Oldest to Newest.
  6. Select OK and review the result, especially the first and last few records.

If you use the A-to-Z or Smallest-to-Largest buttons directly, Excel may display a warning when it detects adjacent data. Choose Expand the selection to include neighboring columns that form the same records, then confirm the sort. If the columns are not related, choose the option to continue with the current selection only—but do so only when you intend to reorder that column independently.

Choose a sort range that keeps records together

The most important decision is what belongs in the sort range. Include every field that describes the records being reordered. If a table has columns for ID, customer, date, and amount, include all four even if you are sorting only by date. Leaving out a related column can make the rows appear correct in one area while the values in the excluded column still refer to the old order.

When the data forms one uninterrupted block, clicking inside it usually lets Excel identify the surrounding region. Do not rely on that automatic detection if there are blank rows, blank columns, or nearby notes. Select the intended range explicitly and check that the first and last columns are included. A title above the table or a note below it should generally remain outside the sort.

  • One header row: Include the header in the selected range and tell Excel that the data has headers.
  • Several separate tables: Sort each table separately unless they are actually one dataset with the same fields.
  • Extra columns tied to each record: Include them even if they are not part of the sort key.
  • Totals or notes: Keep them outside the sortable records, or verify that they are handled as intended.

A useful safeguard is an ID column containing a unique value for each record. After sorting, you can check a few IDs against their associated fields. An ID does not prevent mistakes, but it makes accidental row mismatches easier to spot.

Sort by multiple columns or custom order

A single sort key is enough when every value is distinct or when ties can appear in any order. If you need a meaningful order among ties, add levels in the Sort dialog. For example, sort a staff list first by Department from A to Z, then by Last Name from A to Z. Excel groups departments and sorts the names within each group.

In the Sort dialog, choose the first column and order, then select Add Level to specify the next column. The top level has priority; later levels are used only when values in the earlier level match. You can add further levels for cases such as Department, then Last Name, then First Name.

Alphabetical order is not always the desired order. A status column might need to appear as “Not started,” “In progress,” and “Complete,” even though that is not the ordinary alphabetical sequence. Use the Sort dialog’s Order list and select Custom List when the order you need is available or can be specified. For simpler categories, a helper column with an explicit ranking can also make the intended order easier to inspect and maintain.

Sort left to right when columns are the records

If each column represents an item and the values in the top row determine the order, use Excel’s left-to-right sort option. For instance, a report might have months arranged across columns, with product names down the first column. Sorting the month columns by their dates should move each month’s entire column of values together.

Open Data > Sort, select Options, choose Sort left to right, and confirm. Back in the Sort dialog, choose the row containing the values to sort and set the desired order. Check the selected range first: every row that must travel with those columns needs to be included. This option changes the orientation of the sort; it is not the normal choice for sorting a list of records by a field.

Use an Excel table for repeat sorting

For a regularly updated list, converting the range to an Excel table can make sorting more convenient. Select a cell in the data and choose Insert > Table, or use Home > Format as Table. Confirm that the range is correct and that My table has headers is selected when the first row contains field names. Tables add filter arrows to the header row, which provide quick ascending and descending sorts for each field.

Sorting from a table’s header arrow sorts the table records together rather than treating the clicked column as an unrelated list. When you add data directly below a table, Excel commonly expands the table to include it, making later sorts easier to manage. Still, check that new rows are actually part of the table and that important adjacent information was not left outside it.

Tables are not required for sorting. A normal range works well for a one-time sort, while a table is often clearer for data that is filtered, expanded, or sorted repeatedly. Sorting a table changes the displayed row order; it does not create a separate sorted copy.

Common sorting problems and how to prevent them

Only one column moved: The selected range may have contained just that column, or you may have chosen to sort the current selection instead of expanding it. Undo immediately with Ctrl+Z on Windows or Command+Z on Mac, then sort the full range. If you have made other edits since the sort, undo may reverse those as well, so inspect the workbook before continuing.

Headers were sorted into the records: Reopen the Sort dialog and check My data has headers. If the header has already moved, undo the sort and repeat it with the correct setting rather than trying to repair the order by hand.

Numbers or dates sort strangely: Some cells may be stored as text while others are real numbers or dates. For example, text that looks like a date may not sort chronologically with actual date values. Check the cell formats and underlying values, and make the entries consistent before sorting. Changing a displayed format alone does not necessarily convert text into a true date or number.

Some records seem missing from the sort: A blank row or column may have caused Excel to detect only part of the data. Select the complete range manually, then sort it. Also check whether the records were already filtered; filtering hides rows from view but is not the same as removing them from the worksheet.

Repeated values appear in an unexpected order: A sort on one field does not define a meaningful order among ties. Add another sort level if tied records need a consistent secondary order. If the same workbook must produce a repeatable sequence, include enough levels to distinguish the records.

Excel for Mac and Excel for the web

On Excel for Mac, the same basic approach applies: select a cell in the data and use Data > Sort to open the sort controls. The dialog and ribbon arrangement can differ from Windows, but the key choices remain the column, sort order, and whether the first row is a header. For a left-to-right sort, look for Options in the Sort dialog and choose the horizontal orientation.

In Excel for the web, select the table or range and use the sorting commands on the Data tab, or use a table header’s filter arrow for a quick sort. The web interface may present fewer controls or arrange them differently from the Windows dialog. If you need a complex multi-level or left-to-right sort and cannot find the needed setting in the web interface, open the workbook in the desktop app and use its Sort dialog.

For keyboard undo, use Ctrl+Z on Windows and Command+Z on Mac. Keyboard shortcuts and some ribbon details differ by platform, so the visible menu command is the safest guide when working in a browser or on a different operating system.

Frequently Asked Questions

How do I sort one column but keep the rows together? Select a cell in the data, choose Data > Sort, and sort by the desired field. If Excel asks whether to expand the selection, choose Expand the selection. This moves each complete record rather than changing the order of one column alone.

Does sorting a column sort the whole worksheet? Excel sorts the selected range or detected data region, not every cell on the worksheet. Include all columns that belong to the same records. Separate tables and unrelated notes should normally be sorted independently or left outside the range.

Can I sort a worksheet by more than one column? Yes. Open Data > Sort, set the primary sort field, and choose Add Level for secondary fields. Excel applies later levels to records tied on the earlier level.

How do I sort columns from left to right? Open the Sort dialog, choose Options, select Sort left to right, and then choose the row that contains the sort values. Include every row that must move with those columns.

Can I undo an Excel sort? Usually, press Ctrl+Z on Windows or Command+Z on Mac immediately after the sort. If you have continued editing, undo may also reverse later actions, so verify the workbook’s state before relying on it.

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.