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.

Is there an easy way to swap the contents of two cells in Microsoft Excel?

By easy, I mean either a keyboard shortcut or menu item, without involving copying to temporary cells or writing VBA scripts or anything like that. In other words, I'm looking for a way to just select two cells and click some menu item or press some key combination that will swap their contents. Surely, there has got to be a way to do this?

share|improve this question
    
This seems like a very specific implementation of a sort, and if its not already present in the advanced sorting options, I'd be surprised if you can find it elsewhere, as a non-VBA solution –  drapkin11 Mar 14 '11 at 16:29
add comment

5 Answers

Select first set of cells to be swapped and hit ctrl+x:

Select the cells BESIDE the ones you want to swap with and hit ctrl++.

share|improve this answer
    
This works only if cells are adjacent. Otherwise the whole stuff is shifted near target cells. –  tumchaaditya Jan 5 at 19:45
add comment

Sometimes, there are two adjoining cells need to be swapped. We can manually do it easily. Look at the following screenshot, I want to swap cell A4 and B4, please do as follows:

  1. Select the cell you want to swap. In this example, select cell A4.

  2. Press Shift key, and put the cursor at the right border.

  3. Then drag the cursor to the right border of cell B4.

  4. When there displays “工”, release the mouse.

  5. And the two cell contents have been swapped.

With this method, we can also swap two adjoining rows or columns.

Source

share|improve this answer
    
This should be the selected anser to me. Thank you! –  Nam G. VU Feb 27 at 6:45
add comment

For the specific case of adjacent cells, you can use the method described in this answer to a similar question.

Basically,

  • select the right or bottom cell
  • hit Ctrl-X
  • select the adjacent cell (i.e. directly above or to the left)
  • hit Ctrl-+

Note you can use the same procedure to swap whole adjacent rows or columns.

share|improve this answer
add comment
up vote 3 down vote accepted

No. There is no way to swap the contents of two cells in Excel, without writing your own macro to do it.

share|improve this answer
add comment

By easy, I mean either a keyboard shortcut or menu item, without involving copying to temporary cells or writing VBA scripts or anything like that. I'm looking for a way to just select two cells and click some menu item or press some key combination that will swap their contents.

Why impose this restriction? Creating a macro makes this trivial. As far as I know, it can't be done any other way. You can assign the macro to a button or hotkey.

Sub Swap()     
    If Selection.Count <> 2 Then     
         MsgBox "Select 2 cells (only) to swap."     
         Exit Sub     
    End If     
    Set trange = Selection     
    If trange.Areas.Count = 2 Then     
         temp = trange.Areas(2)     
         trange.Areas(2) = trange.Areas(1)     
         trange.Areas(1) = temp     
    Else     
         temp = trange(1)     
         trange(1) = trange(2)     
         trange(2) = temp     
    End If     
End Sub     
share|improve this answer
    
I'm not a VBA expert and have neither the time nor the inclination to become one. I also frequently use many different computers. It would be nice to have swapping available on every computer I use for Excel, without having to look-up the code for the VBA macro that does it, so that I can bind it to a hotkey. –  Dan Moulding Mar 14 '11 at 19:16
2  
@Dan It would be nice if everyone could have their pet functionality built into Excel, but then it would become even more a bloated mess than it already is. There is a reason why Excel has a macro language, to automate repetitive tasks like this. I posted code found through a google search. You don't have to be an expert. –  ghoppe Mar 14 '11 at 19:29
    
+1 vba is the way excel allows you to add your pet functions. there are also ways of making that vba avaliable on many computers, to just yourself or to all (eg personal workbook, or addins) –  chris neilsen Mar 18 '11 at 23:34
3  
I would hardly call swapping the content of two cells / rows /columns to be a pet function. –  Nicolai Feb 17 '12 at 11:35
3  
@ghoppe Maybe not essential, but if you do a quick search on "swap the content of two cells in excel" (which you already have) it is quite obvious that Dan and I are hardly the only ones that care about this feature. –  Nicolai Feb 21 '12 at 13:57
show 1 more comment

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.