Sort Last Names in Excel: Keep Rows Together

Are you working with a large Excel dataset and need to sort it by last name while keeping rows together? You're in the right place. In this guide, we'll walk yo...

Are you working with a large Excel dataset and need to sort it by last name while keeping rows together? You're in the right place. In this guide, we'll walk you through a simple yet powerful method to achieve this, ensuring your data remains organized and easy to navigate.

How to split full name to first and last name in Excel?
How to split full name to first and last name in Excel?

Before we dive in, let's assume you have a dataset similar to this:

How to Sort Names Alphabetically in Excel
How to Sort Names Alphabetically in Excel
First NameLast Name
JohnDoe
JaneSmith
MichaelJohnson
EmilyDavis

Now, let's sort this by last name while keeping rows together.

[EP 6] Excel Tips Separate First and Last name
[EP 6] Excel Tips Separate First and Last name

Using Flash Fill in Excel

Excel's Flash Fill feature can help you sort data by last name efficiently. Here's how to use it:

Excel Joining Two Text Columns First Name Last Name with Concatenation
Excel Joining Two Text Columns First Name Last Name with Concatenation

1. **Select your data**: Click on the cell with the first name, then drag your cursor to select all the first name cells.

Using Flash Fill

2. **Flash Fill suggestion**: After selecting, you'll see a small lightbulb icon appear in the bottom-right corner of the selected cells. Click on it.

Extract Last Name using TEXTAFTER function in Excel
Extract Last Name using TEXTAFTER function in Excel

3. **Accept the suggestion**: In the dropdown menu, click on 'Flash Fill'. Excel will automatically suggest a column for last names. If it's correct, click 'OK'.

Sorting the Data

4. **Sort by last name**: With your last name column selected, click on the 'Sort & Filter' button in the 'Home' tab. Then, choose 'Sort A to Z' or 'Sort Z to A' depending on your preference.

How To Split First and Last Name in Excel Sheet - How to Split Cells in Excel
How To Split First and Last Name in Excel Sheet - How to Split Cells in Excel

5. **Keep rows together**: After sorting, your data will be sorted by last name, but rows might not be together. To fix this, select the entire dataset, go to the 'Data' tab, and click on 'Remove Duplicates'. In the dialog box, uncheck 'My data has headers' if your data doesn't have headers, then click 'OK'.

Using Power Query in Excel

How to Sort by Name in Excel (3 Examples) - ExcelDemy
How to Sort by Name in Excel (3 Examples) - ExcelDemy
How to Sort by Last Name in Excel - 5 Methods - ExcelDemy
How to Sort by Last Name in Excel - 5 Methods - ExcelDemy
How to Separate First Names and Last Names Into Separate Fields in a Microsoft Excel List
How to Separate First Names and Last Names Into Separate Fields in a Microsoft Excel List
Merge Two Columns in Excel with First Name and Last Name - ExcelDemy
Merge Two Columns in Excel with First Name and Last Name - ExcelDemy
989K views ยท 11K reactions | ๐Ÿƒโ€โ™‚๏ธ๐Ÿ”ฃ๐Ÿ’ก Excel's Flash Fill feature can quickly separate First Name, Middle Name, and Last Name from a full name, or even First Name, Initial, and Last Name, saving you time a | Excel Formulas Unleashed
989K views ยท 11K reactions | ๐Ÿƒโ€โ™‚๏ธ๐Ÿ”ฃ๐Ÿ’ก Excel's Flash Fill feature can quickly separate First Name, Middle Name, and Last Name from a full name, or even First Name, Initial, and Last Name, saving you time a | Excel Formulas Unleashed
Excel
Excel
How to Separate First and Last Names in Excel
How to Separate First and Last Names in Excel
Split First & Last Name Using Power Query | MyExcelOnline
Split First & Last Name Using Power Query | MyExcelOnline
Handling Names Excel
Handling Names Excel
How to highlight certain rows in your data.
How to highlight certain rows in your data.
Separate first and last names in an Excel spreadsheet or Google Sheets
Separate first and last names in an Excel spreadsheet or Google Sheets
How to Sort Data in Excel Without Mixing Up Rows
How to Sort Data in Excel Without Mixing Up Rows
How to create a list of all worksheet names from a workbook?
How to create a list of all worksheet names from a workbook?
Sortby Function in Excel
Sortby Function in Excel
Auto Highlight Row in Excel ๐ŸŒŸ EASY Tutorial ๐Ÿ”ฅ || Excel Tips
Auto Highlight Row in Excel ๐ŸŒŸ EASY Tutorial ๐Ÿ”ฅ || Excel Tips
Sort data by color in Excel
Sort data by color in Excel
a green poster with the words highlight every other row in excel and an image of a
a green poster with the words highlight every other row in excel and an image of a
How to Delete Blank Rows in Excel (6 Ways) - ExcelDemy
How to Delete Blank Rows in Excel (6 Ways) - ExcelDemy
How To Parse Names In Excel | Daves Computer Tips
How To Parse Names In Excel | Daves Computer Tips
Excel Sort by Column or Row One or Multiple Sort by Cell Color Font Color Customize Sort
Excel Sort by Column or Row One or Multiple Sort by Cell Color Font Color Customize Sort

If Flash Fill didn't work as expected, you can use Power Query, a powerful tool for data manipulation. Here's how:

1. **Launch Power Query**: Click on the 'Data' tab, then 'Get & Transform Data', and finally 'From Table/Range'.

Transforming the Data

2. **Create a new column**: In the 'Home' tab of the Power Query Editor, click on 'New Column'. In the formula bar, enter the following formula: `= Table.Column([First Name], "Last Name")`. This creates a new column with last names.

3. **Sort the data**: Click on the 'Home' tab again, then 'Sort'. In the dropdown menu, choose 'Sort by Column'. Select the last name column and choose 'Descending' or 'Ascending' depending on your preference.

Loading the Data

4. **Close & Load**: Once you're satisfied with the sorted data, click on the 'Home' tab, then 'Close & Load'. Choose 'Table' and click 'OK'.

Your data is now sorted by last name, and rows are kept together.

Remember, keeping your data organized is key to efficient analysis. Sorting by last name while keeping rows together ensures your dataset remains easy to navigate and understand. Happy sorting!