Quickly split first and last names into separate cells, with Excel tricks or formulas. See how to reverse order of names, from "Smith, Mary" to "Mary Smith", by using the MID function.
In column A, there is a list of names, with the last name, followed by a command, and then the first name(s). A quick way to separate the names, and split them into two separate columns, is to use the Text to Columns feature.
NOTE: This list is in a named Excel Table. You can follow the same steps for a regular list on a worksheet.
Before splitting the names into separate cells, follow these steps, to remove the space after the comma. Otherwise, a space will appear before the first name, when it is sent to its own column. It would take extra steps to clean it up in that cell.
Before you begin, make a backup copy of the worksheet, or the workbook, just to be safe.
Next, we'll use the Text to Columns feature to split the cell contents into separate columns, based on the position of the comma..
In the Data preview window, you can see where the names will split. Because we removed the space after the comma, there is no space character before the first names.
If we hadn't removed the space after the comma, you would see a space character before each of the first names.
On the worksheet, the last names are in column A, and the first names have moved to column B.. Because the list is a formatted Excel table, a new column was automatically added to the table, with the default heading, "Column1".
In column A, there is a list of names, with the last name, followed by a command, and then the first name(s). In Excel 2013, and later versions, you can use the Flash Fill feature, to quickly reverse the order of the names, to show the first name, then a space, and then the last name.
NOTE: This is a static fix -- the reversed names are not linked to the original names, and will not update if the full name is changed. For a dynamic fix, use the Reverse Names formula, in the next section
As you type, the Flash Fill feature detects a pattern, and fills in the remaining cells, based on that pattern. The list is in a light font color.
The suggested items are entered in the remaining cells, and the font changes to a dark color.
Thanks to Karen Roem, who sent these steps for using the Flash Fill Shortcut - Ctrl + E.
TIP: The same shortcut works to Flash Fill other changes, such as changing text case to Proper, UPPER or lower.
REMEMBER: This is a static fix -- the reversed names are not linked to the original names, and will not update if the full name is changed, or if new names are added. For a dynamic fix, use the Reverse Names formula, in the next section.
You can also reverse first and last names with a formula. Using a formula creates a dynamic fix, instead of a one-time solution. The formula results will update immediately, if the full name in column A is changed.
This video shows the steps, and there are written steps below the video.
In column A, there is a list of names, with the last name, followed by a comma, and then the first name(s).
Follow these steps to create a formula to reverse first and last names:
The formula uses the MID function, which has 3 arguments (text, start_num, num_char)
Text: The & operators join two copies of the full name, with a space between them
Smith, Mary Smith, Mary
Start_Num: FIND function returns the position of the comma-space, and 2 is added to that number. In this example, the comma is the 6th character, so the Start_Num is 8 (6+2)
Num_Char: LEN function returns the number of characters in the full name. The comma will not be in the reversed name, so 1 is subtracted from the length. In this example, the length is 11, so the Num_Char is 10 (11-1)
Result - In cell B2, the result is Mary Smith.
It starts at the 8th character of "Smith, Mary Smith, Mary", and returns 10 characters.
Download the sample file for splitting and reversing full names. The zipped file is in xlsx format, and does not contain macros.
Don't miss my latest Excel tips and videos! Click OK, to get my weekly newsletter with Excel tips, and links to other Excel news and resources.
Last updated: April 20, 2021 12:04 PM
Contextures RSS Feed