How to Sort by the Last Name in Excel?
Last Updated :
03 May, 2022
When you work on excel you'll probably be assigned a task to sort data alphabetically in ascending or descending order and it is quite an easy task to sort data using the first names in either of the order. It is the easiest task to be done in excel. But what if you are given a task to sort a list of names according to their last name in ascending or descending order. Quiet confusing, right?. This article will help you to understand the ways in which you can sort data according to the last name from the data set given to you in three ways by using built-in Microsoft Excel functions.
Sort Using Flash Fill
Flash Fill is an addition to Microsoft Excel 2013 that will automatically fill your data when it senses a pattern. For example, Flash Fill can separate first and last names from a single column or combine first and last names from two different columns.
Note: Flash Fill feature is added in MS Excel 2013 and it will be available in 2013 and later versions of excel.
For Example:
Step 1: Write the last name from the names given in the list to
cell D1. Write at least 2 last names into column D. (as shown below).
Step 2: Select both cells and hover the cursor over the bottom-right part of the selection(as shown in a circle below). You will notice that the cursor changes to a plus icon.
Step 3: Drag the plus icon to the last entry of your data. You'll notice an AutoFill Option (Marked in a circle below, Fig.1 ). Click on the AutoFill option, and a drop-down menu will appear in which you have to select Flash Fill (Fig. 2).
Fig. 1
Fig. 2You'll see all the last names are now in column D.
Step 4: Select the entire dataset and click on Data Tab> Sort & Filter > Sort (as shown below).
Step 5: A dialogue box will appear(as shown below). In the Sort by option add the column name, here column name to be sorted is D. In the Order option, select the order in which you want to sort your data, and in Sort On option select values because we have text as values in the cell. Click OK
Output: The data will be sorted alphabetically according to last names. Delete the last names written in Column D and you'll get the desired output.
Sort Using Find and Replace
As the name suggests, Find and Replace is a functionality that helps us to find a value or number in the sheet and replace it with the desired number or value. It is used when we have mistakenly typed the wrong spelling everywhere in the sheet and need to correct it. It will take a lot of time to find the wrong spelling one by one and then replace it. The example would be taken as above.
Step 1: Copy the data that needs to be sorted into the adjacent column. (as shown below)
Step 2: Select the copied data, in our example select the data from column D and press Ctrl+F to open the find and replace dialogue box (as shown below).
Step 3: In the dialogue box open the Replace option and put an asterisk (*) followed by a single space in Find what field. Leave the Replace with empty. And press Replace All (as shown above). The output will only have last names in the D column.
Note: The above steps work well even when you have middle names or prefixes (such as Mr. or Ms) in your data. It will only return last names.
Step 4: Select the entire dataset and click on Data Tab> Sort & Filter > Sort (as shown below).
Step 5: A dialogue box will appear(as shown below). In the Sort by option add the column name, here column name to be sorted is D. In the Order option, select the order in which you want to sort your data, and in Sort On option select values because we have text as values in the cell. Click OK
Output: The data will be sorted alphabetically according to last names. Delete the last names written in Column D and you'll get the desired output.
Sort Using Text to Columns
Text to Columns is a function provided by MS Excel that helps you to split text written in one cell into multiple cells. The example would be the same.
Step 1: Select the data and go to Data Tab>Sort & Filter> Text to Columns
Step 2: A dialogue box will appear(as shown below). Select Delimited and press Next> button.
Step 3: Click on Space, if your delimiter is a comma or semicolon instead of space click on that. Now click Next> (as shown below).
Step 4: Select General in Column data format and add the cell value adjacent to the original data in Destination and click Finish.
The output will look like this.
Now repeat steps 4 and 5 from Sort using Flash Fill and you'll be done. But remember now your data through which you want to sort is in Column E.
Similar Reads
Non-linear Components
In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Spring Boot Tutorial
Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML)
A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Steady State Response
In this article, we are going to discuss the steady-state response. We will see what is steady state response in Time domain analysis. We will then discuss some of the standard test signals used in finding the response of a response. We also discuss the first-order response for different signals. We
9 min read
Backpropagation in Neural Network
Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
Polymorphism in Java
Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read
3-Phase Inverter
An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read
What is Vacuum Circuit Breaker?
A vacuum circuit breaker is a type of breaker that utilizes a vacuum as the medium to extinguish electrical arcs. Within this circuit breaker, there is a vacuum interrupter that houses the stationary and mobile contacts in a permanently sealed enclosure. When the contacts are separated in a high vac
13 min read
AVL Tree Data Structure
An AVL tree defined as a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees for any node cannot be more than one. The absolute difference between the heights of the left subtree and the right subtree for any node is known as the balance factor of
4 min read
What is a Neural Network?
Neural networks are machine learning models that mimic the complex functions of the human brain. These models consist of interconnected nodes or neurons that process data, learn patterns, and enable tasks such as pattern recognition and decision-making.In this article, we will explore the fundamenta
14 min read