Flip surname-first fields at a separator

Turn de la Cruz|Mary Ann into Mary Ann de la Cruz, with the separator from column B.

What you'll make

In Excel: de la Cruz|Mary Ann + | becomes Mary Ann de la Cruz.

The formula

The formula, with a numbered bracket under each part.
NumberPartWhat it doesResult so far
1TEXTAFTER(A8,B8)Takes the given names after the separator."Mary Ann"
2" "Adds a space."Mary Ann "
3TEXTBEFORE(A8,B8)Adds the surname from before the separator."Mary Ann de la Cruz"
4TRIM( … )Removes any extra spaces."Mary Ann de la Cruz"
5IFERROR( … )With no separator, keeps the name as it is."Mary Ann de la Cruz"

Read it left to right. A cell with no separator stays as it is.

=IFERROR(TRIM(TEXTAFTER(A8,B8)&" "&TEXTBEFORE(A8,B8)),TRIM(A8))

How to use it

Yellow bar at the top? Click Enable Editing.

  1. See it work. The Example tab shows 20 made-up names with the formula already in.
  2. Use your own names. Paste surname-first names into column A of the Template tab and their separator into column B. Given names first fill in by themselves.
  3. Move them into your letter. Copy the results. Then use Paste Special and choose Values.

Before you send

Type the separator exactly as it is in the cell. Each name should have it only once.

Route: Get names ready for the letter

Microsoft's help: TEXTAFTER function