View Single Post
  #1   Report Post  
Sterling
 
Posts: n/a
Default Swap contents of two cells

I need some help with the code for a VBA routine that will swap the contents
of two cells. Here's what I want to be able to do...ctrl-highlight 2 cells
then click on a button that will swap the contents of those two files. They
won't be formulas so I don't have to worry about cell references. I would
prefer that the formatting not be copied, only the values. I've seen code
like this:

Private Sub CommandButton1_Click()
cel1 = InputBox("First cell?")
cel2 = InputBox("Second cell?")
c1 = Range(cel1).Value
c2 = Range(cel2).Value
Range(cel1).Value = c2
Range(cel2).Value = c1
End Sub

But I'd rather not use the InputBox to enter the cells.
Thanks.