Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
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

5 Answers 5

up vote 6 down vote accepted

If the words are next to each other,

Turn on "Use Wildcards"

Find: (1stword) (2ndword)

Replace: \2 \1

share|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

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
share|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

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
share|improve this answer

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

share|improve this answer

I have just discovered myself, this is easiest done in Microsoft Excel:

  1. Open an Excel workbook and paste the data to be "swapped" into the spreadsheet.
  2. First thing is to make sure you have a blank column next to where the split will happen, so insert columns as necessary.
  3. Highlight the column that you want to separate.
  4. From the Data Group tab, select Text to Columns, the "Convert Text to Columns Wizard" will open up.
  5. Excel will determine the Original Data Type for you (if each set of data has the same number of characters, fixed will be selected. If not, delimited will be.) Click next
  6. If your current data is separated by one of the Delimiters listed (normally space), select that and click next.
  7. Select the type of Column Data Format (text, number, etc.), click finish.
  8. It may ask you if you want to replace the contents of the destination cells-click "ok"

If you don't want to leave it in an Excel Spreadsheet, you can copy and paste (either as text or table) into a Word document.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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