up vote 1 down vote favorite
share [g+] share [fb]

If I have a Word-document and want 2 words next to each other to change places with oneanother is that possible with some function or logic in Word?

link|improve this question

61% accept rate
As I guess it's not as simple as "cut word A, move to word B, paste word A, cut word B, move to former position of word A, paste word B", can you be more specific? Do you want to do this in a macro? In the "search and replace" dialog? With 1 command and the 2 words selected? ... – Snark Sep 7 '09 at 11:37
I wonder how smart Word is, thats the default action with cut etc..but I wonder if there is some swapfunction in Word, I know there are functions for Word if you have a table with FALSE, NOT OR and so on but I havent found any functions "outside a table", but is there? – Chris_45 Sep 7 '09 at 11:49
feedback

4 Answers

up vote 5 down vote accepted

If the words are next to each other,

Turn on "Use Wildcards"

Find: (1stword) (2ndword)

Replace: \2 \1

link|improve this answer
But what if they are not next to each other? – Chris_45 Sep 8 '09 at 8:18
You'd need to be better at formulating regular expressions than I am. This might help office.microsoft.com/en-gb/word/HA010873041033.aspx – Bonus Sep 8 '09 at 9:21
This is ok when they are as you say next to each other. Thanks. – Chris_45 Sep 8 '09 at 14:40
feedback

Not sure I understand your question but you can use search and replace like this:

  1. Replace the first word with something random
  2. Replace the second word with the first word
  3. Replace the random word with the second word
link|improve this answer
This is the easiest way to do it. – alex Sep 7 '09 at 11:51
What the hardest way to do it? – Chris_45 Sep 7 '09 at 12:07
Modify each work by hand :). I can think of other ways... – alex Sep 7 '09 at 12:11
1  
There is no hardest way, I assure you. I can think of infinitely hard ways to do it. – waiwai933 Sep 7 '09 at 12:29
1  
And why do you need the hardest way in the first place? Like, you have an easy life without any problems and you are bored, so you start making up problems to spice up your life? :) Well, I dunno, join the army? Or jump off a plane with a parachute? :] – Slink84 Sep 8 '09 at 10:50
feedback

If you want some VBA to swap two adjacent words around, this will do it:

Sub SwapWords()
    'Clear Selection
    Selection.SetRange Start:=Selection.Start, End:=Selection.Start
    'Expand Selection to word under cursor
    Selection.Expand
    'Cut word
    Selection.Cut
    'Move one word right
    Selection.MoveRight Unit:=wdWord
    'Paste word
    Selection.Paste
End Sub
link|improve this answer
feedback

Random words are not needed if you have two exact word separated by a single space (or some similar CONSISTENT layout)

Use Find and replace to search for word1 word2 and replace with word2 word1

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.