How to Sort Alphabetically in Excel Without Mixing Rows

Formulas & functions · Updated November 18, 2026

To sort alphabetically in Excel for Microsoft 365 on Windows, select a cell in the column, then choose Data > Sort A to Z for ascending order or Data > Sort Z to A for descending order. If Excel asks, choose Expand the selection so each row’s related information stays together.

What alphabetical sorting does

Sorting rearranges records according to values in a chosen column. For a contact list, an A-to-Z sort by Last Name puts names beginning with A before names beginning with Z; the other cells in each contact’s row should move with that name. Z-to-A reverses the order. Sorting changes the arrangement of the data in the worksheet, rather than merely hiding records.

Excel sorts text according to its sorting rules and the workbook’s language and regional settings. Uppercase and lowercase letters are generally treated as equivalent in an ordinary sort. Accented letters, punctuation, spaces, numbers stored as text, and mixed data types can produce results that look surprising if you expect a particular dictionary order. When that distinction matters, clean or standardize the data before sorting, or review the sort options.

Sorting is different from filtering. A sort changes the order of the rows; a filter temporarily displays only records that meet selected conditions. You can apply both, but filtering a list does not alphabetize it by itself.

Prepare the data before sorting

A dependable sort starts with a clearly structured list. Use one row for column headings and one row for each record. For example, a staff list might have columns for First Name, Last Name, Department, and Start Date. Avoid blank rows or blank columns in the middle of the list, since they can make it harder for Excel to identify the entire data region.

Before sorting, check that each record’s information is on the same row and that the column you want to sort contains consistent values. A surname column containing names in some rows and comments in others may sort technically, but the outcome will not be a clean surname list. If there are duplicate names, keep a second column such as Employee ID so each record remains identifiable.

  • Include the headings. A clear header row helps Excel distinguish labels such as “Last Name” from the records below them.
  • Check for merged cells. Merged cells can prevent a range from sorting normally. Unmerge them and use a consistent value in each record where possible.
  • Look for stray spaces. Leading spaces can make a name appear out of order. In a spare column, a cleanup formula can remove extra spaces at the start and end and reduce repeated spaces between words.
  • Make a backup for important data. Sorting is reversible with Undo immediately afterward, but saving a copy is prudent before substantial data changes.

If the list will grow or be sorted often, consider converting it to an Excel table. Select a cell in the data and choose Insert > Table, confirm the range, and indicate whether the table has headers. Tables provide filter and sort controls in their header cells and generally keep each record’s columns together as the table is sorted.

Sort one column while keeping rows together

For a simple list, click a cell in the column you want to use as the sorting key. On the Windows ribbon, open Data and select Sort A to Z or Sort Z to A in the Sort & Filter group. You can also use the corresponding ascending or descending sort buttons on the Home > Sort & Filter menu.

If the selected cell is inside a regular data range, Excel may ask whether to expand the selection. Choose Expand the selection when the neighboring columns belong to the same records. If you choose to continue with the current selection, Excel sorts only the selected cells; names can then become paired with the wrong addresses, dates, or other details. Continue with the current selection only when the column is genuinely independent.

For more control, select a cell in the list and choose Data > Sort. In the Sort dialog box, select the column under Sort by, choose Values under Sort On, and choose A to Z or Z to A under Order. If the first row contains labels, make sure My data has headers is selected. Review the range shown in the dialog before confirming.

In an Excel table, use the arrow in the relevant header and choose an ascending or descending sort. The table sorts as a unit, so the values in each row remain associated. Excel for Mac also provides sorting through the Data tab and table-header menus, though ribbon placement and labels can differ slightly by release. Excel for the web offers the same basic ascending and descending choices from the ribbon or a table header; its dialog and options may be more limited than the Windows desktop app.

Sort by more than one column

A single sort key cannot fully order records that share the same value. For instance, sorting a staff list by Department groups staff alphabetically by department, but it does not specify the order of people within each department. Use multiple levels to create a primary order and one or more tie-breakers.

  1. Select a cell in the list and choose Data > Sort.
  2. Set the first level in Sort by, such as Department, and select the desired order.
  3. Choose Add Level. Set Then by to Last Name and choose A to Z.
  4. Add another level if needed, such as First Name, then confirm that the header setting and range are correct and select OK.

With Department as the first level and Last Name as the second, Excel groups departments in the chosen order and sorts names alphabetically within each group. The sort level order matters: Excel applies the first level before using later levels to order ties. In the Sort dialog, the up and down controls let you change the priority of levels.

Multiple levels are useful for product lists, schedules, and inventories too. You might sort by Category, then Product Name, then Size. If you want the largest sale within each salesperson’s group, make Sales the second level and choose largest-to-smallest for that level. Sorting by a numeric or date column is not alphabetical, but the same dialog supports those values and can combine them with text-based levels.

Use custom orders and sort options

Alphabetical order is not always the order people need. A worksheet may need weekdays in calendar order, months from January through December, or priority labels in the order High, Medium, Low. In the Sort dialog, open the Order list and choose Custom List when that option is available. Select an existing list or enter the sequence you need, then apply it to the selected sort level. Excel includes common custom sequences such as days and months; a custom list is useful when ordinary A-to-Z order would be misleading.

The Sort dialog also supports sorting by cell color, font color, and conditional-formatting icon when the data contains those visual indicators. Choose the relevant option under Sort On, then set the color or icon and its position. This can bring flagged records to the top without changing their text. Check that the selected range includes the full records, just as with a normal value sort.

For special text handling on Windows, open Data > Sort, select Options, and review the available settings. The dialog includes a case-sensitive option, which is normally unnecessary for names but can matter for codes where capitalization has meaning. Sort orientation can also be changed to sort left to right rather than top to bottom; that is for arranging columns by values in a row, not the usual way to alphabetize a list.

Sort with a formula instead of moving the source data

If you want an alphabetized view while preserving the original order, Microsoft 365 includes the dynamic-array function SORT. The formula displays sorted results in another area of the worksheet; it does not rearrange the source cells. This is useful for reports or lists where the original sequence must remain intact.

With names in A2:A10, enter =SORT(A2:A10) in an empty cell outside the source range. Excel returns the names in ascending order and spills the results into the cells below. To sort the same range in descending order, use =SORT(A2:A10,1,-1). Leave enough empty cells for the results to spill; otherwise Excel may display a spill error. The source values remain in their original locations.

To sort whole records by a particular field, include all the relevant columns in the source array. With names in A2:A10 and departments in B2:B10, for example, the two-column records are in A2:B10. Enter =SORT(A2:B10,1,1) in an empty area to sort those rows by the first column in ascending order. For records that should be ordered by a key outside the returned range, SORTBY can sort an array using a separate key range. These functions are available in Microsoft 365 and Excel 2021 or later; dynamic-array behavior and availability depend on the Excel version.

Formula-based sorting is not a replacement for every manual sort. It creates a separate view, and edits to the source can change the displayed order as the formula recalculates. If you need to permanently rearrange the actual records, use the ribbon sort instead. Also avoid placing the formula inside the range it refers to, which can create a circular reference or prevent the results from spilling.

Common sorting problems and how to fix them

Rows no longer match: The most serious mistake is sorting one column without its related columns. Undo immediately with Ctrl+Z on Windows, or Command+Z on Mac, then sort the full range or use the table header. If the workbook has been closed or further edits have been made, Undo may no longer restore the original arrangement, which is why a backup is useful.

A header is sorted into the records: Open Data > Sort and check My data has headers. If Excel did not recognize a heading automatically, selecting this option keeps it out of the sorted records. Conversely, do not mark the first data row as a header if the range has no heading.

Names appear in an unexpected order: Look for leading spaces, inconsistent punctuation, abbreviations, or values stored in different formats. A name beginning with a space may appear before names beginning with a letter. For cleanup, with source text in A2, enter =TRIM(A2) in B2 and fill down, then use the cleaned values for the sort or copy and paste them as values if you need to replace the originals. TRIM removes ordinary extra spaces, but it does not remove every kind of nonprinting character.

Numbers sort strangely: A column may mix numbers with text that looks like numbers, such as a value entered with an apostrophe or imported from another system. Excel may treat these as different types, so check the cell formats and data consistency. Convert values to a consistent type before sorting if numeric order is important. A-to-Z sorting is not a way to correct inconsistent data.

Only part of the list moved: Blank rows or columns may have caused Excel to detect a smaller range. Select the complete dataset before sorting, or convert it to a table and sort from a header. Inspect the range in the Sort dialog before confirming, especially when the worksheet contains nearby notes or separate lists.

Frequently Asked Questions

How do I alphabetize a column in Excel?
Select a cell in the column and choose Data > Sort A to Z. If the column is part of a larger list, expand the selection so the other values in each row move along with it.

How do I sort by last name when full names are in one column?
A basic A-to-Z sort orders the text from the start of each cell, so it sorts full names by first name if first name comes first. For reliable last-name sorting, put last names in a separate column and sort by that field, or use a carefully designed formula or data-cleaning step when the names have consistent formatting.

Can I sort alphabetically in Excel without changing the original list?
Yes. In Microsoft 365 or Excel 2021 and later, use SORT in an empty area to create a separate sorted result. The formula returns a sorted view while leaving the source range in place.

How do I sort by last name and then first name?
Choose Data > Sort, set Last Name as the first level, then choose Add Level and set First Name as the second level. This sorts first by surname and uses given name to order people with the same surname.

Why does Excel sort numbers before letters?
Excel distinguishes numeric values from text values when sorting a mixed column. A column containing both can therefore group numbers and text differently from a purely alphabetical list. Use consistent data types, and check whether number-looking entries are stored as text.

Can I sort only the visible rows?
Filtering hides records that do not meet the filter criteria, but sorting a filtered list can still affect the underlying range. If you need a separate output containing only visible or qualifying records in a particular order, use a filtered view or a formula-based result appropriate to your Excel version, and verify the output before replacing source data.

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.