![]() |
#1
|
|||
|
|||
![]()
I need a macro that will replace the first word with the second one...
Example: - John Johnson - Patrick Something - Annie Bunny Convert to.... - Johnson John - Something Patrick - Bunny Annie Can anyone help? Thnx in advance... |
#2
|
|||
|
|||
![]()
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 |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Takket | Word VBA | 2 | 03-28-2014 04:58 PM |
I need a macro, who can help me? | Bahir Barak | Word VBA | 1 | 05-26-2010 12:24 AM |
Macro help | NEHicks503 | Excel | 0 | 04-16-2010 07:29 AM |
Word macro | weezypenguin | Word | 0 | 02-25-2010 01:25 PM |
![]() |
TAFE | Word | 4 | 11-04-2009 02:50 AM |