Skip to main content

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 last 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 will be time-consuming and tedious if you use these traditional methods. Actually, there are several easy ways to flip or reverse the first name and last name in a single column quickly. Supposing you have a column of names, and you need to flip the first and last name as below screenshot shown:
doc flip first last names 1

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 Excelgood idea3

Split full name into first name and last name with Kutools for Excelgood idea3


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

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

 Enter the formula =MID(A2&" "&A2,FIND(" ",A2)+1,LEN(A2)) in a blank cell, says Cell C2. And then drag the fill handle down to the cells to apply this formula, then you can see all first and last names have been revered. See screenshot:

doc flip first last names 2


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.

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

2.  Click Insert > Module, and paste the following macro in the Module window.

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

3.  Press the F5 key to run this macro. In the popping up KutoolsforExcel dialog box, select the range to flip, and then click the OK button. See screenshot:

doc flip first last names 3

4.  In the following popping up dialog box, please enter an interval symbol (such as a space), and then click the OK button. See screenshot:

doc flip first last names 4

5. Now the first name and last name in selected range are flipped. See screenshot:

doc flip first last names 5


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: A handy Excel add-in tool,makes your jobs more easier and efficiency.
  • 300+ powerful and easy-to-used functions,110,000+ Excel users'choice
  • full-featured free trial in 30 days, no credit card required
  • dozens of one-click functions to shrink your working time on solving complex problems
  • includes functions to batch converion,deletion,combining sheets/cells,exproting, ect, free try now.

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

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

2.  Click Kutools > Text > Reverse Text Order, see screenshot:

doc flip first last names 8

3.  In the Reverse Text dialog box, specify a separator your selected text string using, (in this case, I select Space option) and then click the OK button. And all the first names and last names in the selected range have been reversed. See screenshot:

doc flip first last names 7

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


Demo: Flip / Reverse the first and last names in cells


Split full name into first name and last name with Kutools for Excel

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

If you have a list of full names which need to split to first name and last name in two columns separately as below screenshot shown, you can apply Kutools for Excel’s Split Names to quickly handle it.
doc flip first last names 9

1. Select the list of names you want to split, click Kutools > Merge & Split > Split Names.
doc flip first last names 10

2. In the Split Names dialog, check First name and Last name checkboxes, if you want to split middle name as well, check Middle name. Click Ok, select a cell to place the split names.
doc flip first last names 11



Kutools for Excel: 300+ functions you must have in Excel, 30-day free trial from here.

Best Office Productivity Tools

Supercharge Your Spreadsheets: Experience Efficiency Like Never Before with Kutools for Excel

Popular Features: Find/Highlight/Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns     Move Columns   |   Unhide Columns   |   Compare Columns to Select Same & Different Cells ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolset12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   Many More...

Kutools for Excel boasts over 300 features, ensuring that what you need is just a click away...

Supports Office/Excel 2007-2021 & newer, including 365   |   Available in 44 languages   |   Enjoy a full-featured 30-day free trial.

kte tab 201905


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (41)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
hola, gracias por tus formulas, como puedo hacer si necesito reversar los nombres y luego los apellidos, por ejemplo tengo esto GRANDA VELASCO OMAR GERMANICO, y con la función revert no me funciona en orden me saca GERMANICO OMAR VELASCO GRANDA, me cambia el orden.
This comment was minimized by the moderator on the site
Hi there,

If you have additional middle names rather than just first and last names, please try the Reverse Text Order feature of Kutools for Excel.
https://www.extendoffice.com/images/stories/comments/ljy-picture/reverse-text.png

If you don't have Kutools for Excel installed in your computer, you can click here to download and try it for free for 30 days: Kutools for Excel. After the installation, you can find the feature on Kutools tab, in Editing group:
https://www.extendoffice.com/images/stories/comments/ljy-picture/reverse-text-2.png

Amanda
This comment was minimized by the moderator on the site
Thank you sooo very much! You made work easier for me!
This comment was minimized by the moderator on the site
=MID(A2&", "&A2,FIND(" ",A2)+1,LEN(A2)+1)

where the name is on the A2 cell
This comment was minimized by the moderator on the site
You saved my life!!! Thank you. None of the others worked. This is exactly what I needed.
This comment was minimized by the moderator on the site
=MID(O4&", "&O4,FIND(" ",O4)+1,LEN(O4)+1)
This comment was minimized by the moderator on the site
okay. can someone say this in english because I have no clue what you guys are talking about
This comment was minimized by the moderator on the site
Try this to add a comma: =MID(A2&", "&A2,FIND(" ",A2)+1,LEN(A2)+1)
This comment was minimized by the moderator on the site
THANK YOU literally I've been trying to figure out the comma thing for like an hour. Thank you!
This comment was minimized by the moderator on the site
What if I need to insert a comma between the last and first name?
This comment was minimized by the moderator on the site
What if there is a comma separating the 2 names? Is there a way to eliminate it? Now the names look like

Arthur Lange,

Eric Norris,

etc etc
This comment was minimized by the moderator on the site
Try this to remove a comma: =MID(A2&" "&A2,FIND(", ",A2)+1,LEN(A2)+1)
This comment was minimized by the moderator on the site
Have you tried Ctrl+F, Select Replace, Find "," and leave replace with blank.
This comment was minimized by the moderator on the site
When I try that, it pops up with this error message "There's a problem with this formula. Not trying to type a formula? When the first character is an equal (=) or minus (-) sign, Excel thinks it's a formula: you type: =1+1, cell shows: 2. To get around this, type an apostrophe (') first: you type: '=1+1, cell shows =1+1.
This comment was minimized by the moderator on the site
I think you are changing the formula. Try copying and pasting the values to a new cell then do the find/replace.
This comment was minimized by the moderator on the site
I want to know this too!
This comment was minimized by the moderator on the site
Correction. What if i have four names? What's the formula? Last name - first name - middle1 - middle2
This comment was minimized by the moderator on the site
If you have middle name how do you flip the last name? Example below. Last name - first name - middle name
This comment was minimized by the moderator on the site
Instead of +1, change the plus factor to two numbers greater than the middle name. This has worked for me.

Arev
This comment was minimized by the moderator on the site
THANKS!!!!! This formula just saved me a bunch of time. I am sure I will use it again and again.
This comment was minimized by the moderator on the site
Please help I need a formula to flip Alexa Victoria G. Garcia to Garcia, Alexa Victoria G. Please help :) Thank you
This comment was minimized by the moderator on the site
A suggestion - In an effort to encourage good programming practices (Option Explicit), please dim all variables.
This comment was minimized by the moderator on the site
I would like excel updates
This comment was minimized by the moderator on the site
Hello, How to reverse the name in the format Lastname,Firstname to Firstname Lastname Lets say Paul,John = John Paul
This comment was minimized by the moderator on the site
Switching around the last, first is actually a little easier because we have that comma to help us. Assume that the name is in cell A1 and the formula used is: TRIM(RIGHT(A1,LEN($A1)-FIND(",",A1,1)))&" "&TRIM(LEFT(A1,FIND(",",A1,1)-1)) I put the TRIM command on both the first and last names to ensure that we are only going to have the single space between the two. Probably doesn't need the TRIM on the last name, but you never know if a space may be the first character of the cell or if there may be a space preceding the comma.
This comment was minimized by the moderator on the site
The first formula worked fine (once I got rid of the middle names). But now I want to alphabetize and it won't do it.......because there's a formula in the cells?
This comment was minimized by the moderator on the site
So there's a long, drawn out way that you can change the format of Lastname, Firstname Middle to Firstname Middlename Lastname.

Assume that Lastname, Firstname Middle is in Cell A1.

Highlight the cell/column that Lastname, Firstname Middlename(s) is in. Click Data tab->Text to Columns. Chose "Delimited" Next-> click all that apply in checklist and double click the line between Firstname and Secondname to remove it, Next-> Finish. Now Lastname is still in A1, and Firstname Middlename in B2.

In a new cell (let's say C1) use the forumla =Concatenate(B1," ",A1) and the name will now read as " Firstname Middlename Lastname" (note the space at the start).

I another cell (let's say D1) use =TRIM(C1) to remove the space.

And you're done! I'm sure there is a much easier process, but that's what works for me.

Cheers!
This comment was minimized by the moderator on the site
Thanks - worked well and saved me a lot of time!
This comment was minimized by the moderator on the site
The Macro worked for me. Thanks!
This comment was minimized by the moderator on the site
I want 20140115 to 15012014
This comment was minimized by the moderator on the site
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?
This comment was minimized by the moderator on the site
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!
This comment was minimized by the moderator on the site
Now use this one and it should work for all cases

=RIGHT(A13,LEN(A13)-FIND("@",SUBSTITUTE(A13," ","@",LEN(A13)-LEN(SUBSTITUTE(A13," ",""))),1))&" "&LEFT(A13,FIND("@",SUBSTITUTE(A13," ","@",LEN(A13)-LEN(SUBSTITUTE(A13," ",""))),1))
This comment was minimized by the moderator on the site
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!
By Mike Gagne


can you help me with this problem?

the original
14D-E13111-00
and i want it to be
E13111-14D-00

Thank you so very much...
This comment was minimized by the moderator on the site
Thanks Mike Gagne its helps me lot. i have big data base of full name i have to sort it by last name first. its give me very big help on that work. thank you again. :lol:
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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?
By CJC


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.
This comment was minimized by the moderator on the site
The first formula works perfectly.
This comment was minimized by the moderator on the site
None of this Works, except for what this person is selling
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations