How to Sort Hyphenated Last Names Correctly in Excel
Question details
The user needs to properly sort a list of names that includes hyphenated surnames in Excel to maintain alphabetical order.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Organizing a spreadsheet containing a list of personal names where some individuals have hyphenated last names.
- Observed behavior
- Excel sorts alphabetically based on the entire cell content, requiring last names to be separated into a dedicated column to ensure the hyphenated surname is treated as the primary sort key.
Before applying a sort, ensure your data is structured in a table format with clear headers, and identify whether the full names are combined in a single cell or already separated into distinct first and last name columns.
Separate Full Names and Sort by the Last Name Column
The most reliable method is to store first, middle, and last names in dedicated columns before applying the sort function.
If your names are currently stored in a single cell (e.g., 'John Lopez-Espinoza'), Excel will sort by the first name. You must first extract the last name into its own column.
Highlight the column containing the full names that you wish to separate.
Navigate to the Data tab and click 'Text to Columns'. Choose 'Delimited', click Next, and check 'Space' as your delimiter to split the names into distinct columns.
Once your first and last names are in separate columns, highlight the entire data range (including headers) to ensure corresponding data stays together during the sort.
Click 'Sort' under the Data tab. In the Sort dialog box, choose your 'Last Name' column in the 'Sort by' dropdown, select 'Cell Values', and choose 'A to Z' as the order.

Extract Last Names Using a Helper Column Formula
Use text extraction formulas to pull the last name into a separate column for sorting without altering the original full-name column.
Sort Complex Data Effortlessly with WPS Spreadsheet
WPS Spreadsheet provides powerful and intuitive data management tools, including an easy-to-use Text to Columns feature and advanced custom sorting, helping you accurately organize datasets involving complex or hyphenated names.
- 1. Open your dataset: Launch WPS Spreadsheet and open the document containing the names you need to sort.
- 2. Separate the names: Go to the Data tab, click 'Text to Columns', and split the full names into distinct First and Last Name columns using a space delimiter.
- 3. Apply the sort: Highlight your table, click the 'Sort' icon under the Data tab, and select the Last Name column to organize your list alphabetically.

Frequently Asked Questions
Will Excel ignore the hyphen when sorting names?
No, Excel recognizes the hyphen as a valid text character. However, because it sorts alphabetically character by character from left to right, a surname like 'Lopez-Espinoza' will be sorted primarily by the letter 'L', keeping it in the expected alphabetical position.
How do I sort names if only some of them are hyphenated?
As long as all last names (both standard and hyphenated) are located in the same dedicated column, you simply select the column and use the A-Z sort function. Excel naturally handles the mixture of single and hyphenated words correctly.
Can I sort the list by the second part of a hyphenated last name?
To sort specifically by the second half of a hyphenated surname (e.g., 'Espinoza' from 'Lopez-Espinoza'), you must first split the name further using 'Text to Columns' with a hyphen (-) as the delimiter, then sort your data based on the newly created column.
Why are my hyphenated names sorting by first name instead?
This happens when the first and last names are combined in the same cell. Excel sorts based on the very first letter it sees in a cell. You must separate the names into distinct columns and sort specifically by the last name column.




