How to flip the first and last name in cells in Excel?

Let's say you get a roster of names in one column, however, you need to flip the first name and late name in cells. Normally you will get into one cell and cut the last name, and then paste it before the first name, or retype the name again. It hears time-consuming and tedious. Actually, there are several easy ways to flip or reverse the first name and last name in a single column quickly.

Flip the first and last name in a column with a function

Flip the first and last name in a column with VBA

Flip the first and last name in a column with Kutools for Excel

Kutools for Excel: add 120 new features in Excel. Save one hour every day.
Classic Menu for Office: brings back classic menus to Office 2010 and 2013 (includes Office 365).
Office Tab: brings tabbed interface to Office as the use of web browser Chrome, Firefox and Internet Explorer.

Supposing you have a column of names, and you need to flip the first and last name, see following screenshots:

doc-flip-first-last-names1-2doc-flip-first-last-names2

arrow blue right bubble Flip the first and last name in a column with a function

Hot
Amazing! Using Tabs in Excel like Firefox, Chrome, Internet Explore 10!

We can use one of Excel's formulas to flip the first and last name quickly in a column with following steps:

Step 1: Enter the formula =MID(A1&" "&A1,FIND(" ",A1)+1,LEN(A1)) in a blank cell, says Cell C1. See screenshot:

doc-flip-first-last-names3

Step 2: Select the range of C1:C10, and click the Home > Fill > Down. Then you will see the first name are last name are inversed. See screenshot:

doc-flip-first-last-names4

Step 3: As they are formulas, when you need to copy them to other cells, please paste as values.


arrow blue right bubble Flip the first and last name in a column with VBA

You can also use VBA macros to flip the first and last name in a column quickly.

Step 1: Hold down the Alt + F11 keys in Excel, and it opens the Microsoft Visual Basic for Applications window.

Step 2: Click Insert > Module, and paste the following macro in the Modulewindow.

Sub FlipName()
'Updateby20131126
Dim Rng As Range
Dim WorkRng As Range
Dim Sign As String
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Sign = Application.InputBox("Symbol interval", xTitleId, " ", Type:=2)
For Each Rng In WorkRng
xValue = Rng.Value
NameList = VBA.Split(xValue, Sign)
If UBound(NameList) = 1 Then
Rng.Value = NameList(1) + Sign + NameList(0)
End If
Next
End Sub

Step 3: Press the F5 key to run this macro. Then you will see a dialig display in the screen for you to select a range to flip, see screenshot:

Step 4: Press OK, then a dialog is popped up for you to define a invertal symbol, see creenshot:

Step 5: Press OK, you can see the result shown as below:


arrow blue right bubble Flip the first and last name in a column with Kutools for Excel

With Kutools for Excel’s Reverse Text Order, you can quickly reverse order of the text in the cells.

Kutools for Excel includes more than 120 handy Excel tools. Free to try with no limitation in 30 days. Get it Now.

If you have installed Kutools for Excel, please do as following steps:

Step 1: Select the range that you want to reverse the first and last names.

Step 2: Click Kutools > Text Tools > Reverse Text Order, see screenshot:

doc-flip-first-last-names5

Step 3: In the Reverse Text dialog box, specify a separator your text string using, in this example, select Space option, and you can see the results from the Preview Pane. See screenshot:

doc-flip-first-last-names6

Step 4: Then click OK or Apply, all of the first names and last names in the selected range have been reversed.

Note: Checking Skip non-text cells to prevent you reversing the numbers in selected range.

If you want to know more about this feature, please click Reverse Text Order.


Kutools for Excel

More than 120 Advanced Functions for Excel 2013, 2010, 2007 and Office 365.

screen shot

btn read more     btn download     btn purchase

Comments  

0#Stacy2013-12-16 00:47
None of this Works, except for what this person is selling
Reply | Reply with quote | Quote
+5#Raymond2013-12-26 14:56
The first formula works perfectly.
Reply | Reply with quote | Quote
0#CJC2014-01-14 14:01
I understand what each part of the formula does (MID, FIND, and LEN), but I don't understand why it's actually flipping the names. Can someone please explain that to me?
Reply | Reply with quote | Quote
0#Mike Gagne2014-05-06 14:21
Quoting CJC:
I understand what each part of the formula does (MID, FIND, and LEN), but I don't understand why it's actually flipping the names. Can someone please explain that to me?


Here's the formula being used:
MID(A1&" "&A1,FIND(" ",A1)+1,LEN(A1))

The Mid function has these components:
Mid("text to use", where to start, num of chars to select)

It works by taking the contents of A1 and putting two copies of it together separated by a space (i.e. A1&" "&A1 = "Jim Green Jim Green".)

The next step then skips the first word (i.e. Find(" ", A1)+1 = "Jim ", so in net effect leaves you with "Green Jim Green" to work with.)

The final step selects the length of the orginal string (i.e. Len("Jim Green") = 9) from the remaining portion of the concatenated string less the first name (i.e. "Green Jim Green")

Hopefully that makes sense.
Reply | Reply with quote | Quote
0#Mike Gagne2014-05-06 14:22
Sadly, the original formula doesn't work correctly if the name includes a middle initial or middle name. So, "Jim R Green" gets you "R Green Jim" when you really want "Green Jim R".

The formula to allow for that to happen is:
=MID(A1&" "&A1,IF(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))=1,FIND(" ",A1)+1,FIND(" ",A1,FIND(" ",A1)+1)+1),LEN(A1))

What I've done with the original formula is just add a test to see if the original name contains more than 1 space and if so, begin my mid function with the second space. Note that it's still not perfect because it doesn't take into account "Jr.", "Sr." or "III", etc. being after the last name, but it's better.

An additional thing to keep in mind is if your data isn't 100% clean and contains leading or trailing spaces, like "Jim R Green ", you'll need to use the TRIM command to clean it up. If you don't, it will throw off the count of spaces and give you a "#value!" error. Use this to ensure no leading or trailing spaces affect your results:

=MID(TRIM(A1)&" "&TRIM(A1),IF(LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))=1,FIND(" ",TRIM(A1))+1,FIND(" ",TRIM(A1),FIND(" ",TRIM(A1))+1)+1),LEN(TRIM(A1)))

You can also alter the formula to include the comma between the last and first names, as in "Green, Jim R", by using this:

=MID(TRIM(A1)&", "&TRIM(A1),IF(LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))=1,FIND(" ",TRIM(A1))+1,FIND(" ",TRIM(A1),FIND(" ",TRIM(A1))+1)+1),LEN(TRIM(A1))+1)

Hope that helps out some!
Reply | Reply with quote | Quote
0#JS2014-05-08 09:16
While the original formula doesn't work for multiple first names or first name + middle name initials (the aforementioned Jim R. Green, or Lee Harvey Oswald, for example), it does work correctly for multi-part surnames, e.g. James Van Der Beek -> Van Der Beek James. If you have one or two instances of people with both multiple first names or middle names combined with a multi-part surname, you're probably best off handling those manually. Or trimming away the extra middle names, or saving the first names and last names in separate columns to begin with, then hiding those columns and combining them however you want for display.
Reply | Reply with quote | Quote
0#Mike Gagne2014-05-09 16:33
That's a really good catch JS, one example that I hadn't thought of testing.

There is another work around that could be done to help with this issue and that is to use a non-breaking space to separate multi-part last names. You may have seen &NBSP used in HTML code. You can insert a non-breaking space into your cell by holding the ALT key and typing the numbers "0160" using the keypad.

I tried it and it works great.
Reply | Reply with quote | Quote
0#Joel2014-07-19 07:42
Please help

What if multiple First name or surname

Example

Nick Van Exel
should appear as VanExel, Nick

Luis Alfred D. Chua
should appear as Chua, Luis D.
Chua, Alfred D.

Jason D. Lee-Parks
should appear as LeeParks, Jason D.
Reply | Reply with quote | Quote
0#vivek2014-01-15 08:56
I want 20140115 to 15012014
Reply | Reply with quote | Quote
0#DiGi2014-01-25 07:13
The Macro worked for me. Thanks!
Reply | Reply with quote | Quote

Add comment


Security code
Refresh