Others

How to Sort Hyphenated Last Names Correctly in Excel

John WilsonJohn Wilson Oct 22, 2026 870 views

Question details

The user needs to properly sort a list of names that includes hyphenated surnames in Excel to maintain alphabetical order.

How to Sort Hyphenated Last Names Correctly in Excel
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 you start

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.

Solution 1Recommended

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.

1
Select the name column

Highlight the column containing the full names that you wish to separate.

2
Apply Text to Columns

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.

3
Select the entire dataset

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.

4
Sort by Last Name

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.

Separate Full Names and Sort by the Last Name Column
Correct Alphabetical Order: Excel treats the hyphenated surname as a single text value. A name like 'Lopez-Espinoza' will sort correctly under 'L', naturally appearing after names starting with 'K'.
Organize Data Easily

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. 1. Open your dataset: Launch WPS Spreadsheet and open the document containing the names you need to sort.
  2. 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. 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.
Seamlessly sorts hyphenated and complex names with precise custom sorting criteria.Fully compatible with Microsoft Excel file formats (.xlsx, .xls) ensuring no data loss.Intuitive Text to Columns wizard for quick separation of combined name strings.Free, lightweight, and user-friendly interface for managing large datasets.
microsoft office alternative - wps office

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.