last name first macro?

  • Thread starter Thread starter redhead
  • Start date Start date
R

redhead

How do I create a last name first macro, or is there a program I can download
easily? I have a .sit nameswap program, but that's not working
 
What do you want to do? Do you have a list of first name last names? I'd use
Excel to do the swapping.
 
It is not always straightforward what constitutes a name, particularly in
the USA, where suffixes such as 'Jnr.' may be added, or where you may have a
double barrelled surname Robertson-Smythe, an abbreviated name St. John or a
surname that comprises more than one word eg von Trapp, or a combination of
one or more of these 'James Robertson-von Trapp Jnr.' A macro that would
work with all eventualities and eliminate false errors attributable to the
surrounding text, is a tall order. However the following will work for
simple two word names including double barrelled surnames separated with a
hyphen. Put the cursor in the first name and run the macro.

Sub TransposeName()
Dim oName As Range
Set oName = Selection.Range.Words(1)
oName.MoveEnd wdWord, 1
oName.Select
Selection.Move wdCharacter, 1
If Selection.Text = "-" Then
oName.MoveEnd wdWord, 2
oName.Text = oName.Words(2) & _
oName.Words(3) & _
oName.Words(4) & _
oName.Words(1)
Else
oName.Text = oName.Words(2) & oName.Words(1)
End If
End Sub
http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top