How to Batch Change the Order of First and Last Name in a List in Word Document

In this post, we are glad to show you the way to batch change the order of first and last name in a list in Word document.

An English name includes the first name, middle name, and last name. And it is written in the very same order. As a result of globalization, people from different regions of culture now exchange with one another more often than at any time. Consequently, there are a lot international conferences nowadays. And names in other language tend to have a different order. Therefore, there are times when you need to change the order of first and last name in a list. The point is how we can do it in batch.Batch Change the Order of First and Last Name in a List

Actually, you can accomplish this in Word with the help of a macro. Follow our instructions bellow.

Change the Order of First Name and Last Name in a List

  1. First and foremost, create a 2-column table of multiple rows in Word.
  2. In the first column, enter names that need to change the sequence. Be careful not to enter any space after names.
  3. Leave the second column blank.
  4. After this, click “Developer” tab and click “Visual Basic” to trigger the VBA editor. If the “Developer” tab is not available, press “Alt+ F11” instead.Click "Developer"->Click "Visual Basic"
  5. Now create a new module by clicking “Normal” in the left column.
  6. Then click “Insert” tab and choose “Module” on its drop-down menu.Click "Normal"->Click "Insert"->Click "Module"
  7. Next double click new module to open it.
  8. And paste the following codes there:
Sub ExchangeNameOrder()
  Dim strOriginalName As String, strNewName As String
  Dim aryOriginalName() As String
  Dim nIndex As Integer
  Dim objTable As Table
  Dim objOriginalName As Cell
  Dim objOriginalNameRange As Range
  Dim objExchangedNameRange As Range
  Dim nRowNumber As Integer
  Set objTable = ActiveDocument.Tables(1)
  nRowNumber = 1
  '  Traversing the names in column 1
  For Each objOriginalName In objTable.Columns(1).Cells
    Set objOriginalNameRange = objOriginalName.Range
    objOriginalNameRange.MoveEnd Unit:=wdCharacter, Count:=-1
    Set objExchangedNameRange = objTable.Cell(i, 2).Range
    objExchangedNameRange.MoveEnd Unit:=wdCharacter, Count:=-1
    strOriginalName = objOriginalNameRange.Text
    aryOriginalName() = Split(strOriginalName, " ")
    '  Exchange the order of first name and last name, and put the new name in column 2.
    If UBound(aryOriginalName) > 0 Then
      strNewName = aryOriginalName(UBound(aryOriginalName))
      For nIndex = 1 To UBound(aryOriginalName) - 1
        strNewName = strNewName & " " & aryOriginalName(nIndex)
      Next nIndex
      strNewName = strNewName & " " & aryOriginalName(0)
      objExchangedNameRange.InsertAfter (strNewName)
      objExchangedNameRange.InsertAfter (strOriginalName)
    End If

    nRowNumber = nRowNumber + 1
  Next objOriginalName
  MsgBox ("The first name and last name have been exchanged the order in column2.")
End Sub
  1. Lastly, click “Run”.Paste Codes->Click "Run"

Now you will receive a message box, informing you the exchange has been completed. You can see names in new order in the second column. Check the result bellow:Swap the Name Order

Your Last Hope of Retrieving Data Back

Inevitably, we would run into Word issues now and then. As sad as it sounds, it’s also very true. But, you need keep in mind that whenever a collapse occurs in Word, there are always things we can do. First try the built-in tool for corrupt word. If it should not help, which is quite the case all the time, you can anchor your hope in an advanced repairing product.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including recover xlsx and pdf repair software products. For more information visit

Leave a Reply

Your email address will not be published. Required fields are marked *