Thread: [Solved] Need help with macro
View Single Post
 
Old 06-17-2010, 02:58 PM
sixhobbits sixhobbits is offline Windows 7 Office 2007
Novice
 
Join Date: Aug 2009
Posts: 6
sixhobbits is on a distinguished road
Default

I'm sure there are more elegant ways, but the following seems to work if the names are all in a column i.e.

John Johnson
Patrick Something
Annie Bunny

Sub switchwords()
Dim ls As Integer
'change following number to number of names you want to change
ls = 1000
Selection.HomeKey unit:=wdStory
Do While ls > 0
Selection.MoveRight unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Cut
Selection.EndKey unit:=wdLine
Selection.TypeText Text:=" "
Selection.PasteAndFormat (wdPasteDefault)
Selection.MoveDown unit:=wdLine, Count:=1
Selection.HomeKey unit:=wdLine
ls = ls - 1
Loop
End Sub

Just make sure to change the ls variable to be not much more than the number of names you have.

Consider using Excel for this - would be much easier.

HTH

SIxhbbits
Reply With Quote