Use Word's Replace to transpose a column of names

Transposing a list of names is a fairly easy task for Word's Replace feature. Susan Harkins shows you how it works.

You'll often see a column of names entered in a Word document either as a list or part of a table. Listing the names is no problem, but changing their order after they're entered could be. For instance, let's say your document contains a list of names entered in firstname lastname format, but you want them in lastname, firstname format. Do you have to re-enter them? No, there's a simple wildcard trick you can use with Word's Replace feature that will take care of the transposing for you.

To get Word to transform a list or column of names, do the following:

  1. Select the list of names you want to transpose.
  2. From the Edit menu, choose Replace. In Word 2010, click Replace in the Editing group on the Home tab.
  3. Click the More button and check the Use Wildcards option. This is an important step—if you miss it, this technique won't work.
  4. In the Find What control, enter (<*>) (<*>), with a space character between the two sets.
  5. In the Replace With control, enter the following characters \2, \1, with a space character before the second slash character.
  6. Click Replace All. Word will transpose the first and last names and separate them with a comma character.
  7. When Word asks you to expand the search, click No, and then Close to return to the document.

Wildcard explanation

Once you understand the wildcards, the whole trick is easily exposed:

  • (): The parentheses aren't true wildcards, not in a matching sense. They allow you to divide a pattern into logical sequences.
  • <>: The brackets mark the beginning and ending of a word or phrase.
  • \: The slash character replaces characters, and is used with a number that specifies a bracketed component (above).
In this case, the Find What code splits the two names into two separate sequences. The \2 component in the Replace What code replaces the contents of the first sequence with the contents of the second sequence. The \1 component replaces the contents of the second sequence with the contents of the first. As you can see, you're not limited to just transposing first and last names. With these wildcard tools, you can rearrange quite a bit of content!

What's the most interesting wildcard code you've used and how to you apply it?

About Susan Harkins

Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.

Editor's Picks