LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fill cells A1, A2, A3... with contents from B1, B4, B7... Xianbo Excel Discussion (Misc queries) 4 October 19th 05 03:51 PM
How do I change a cell's contents to it's formula's value? Cindy Excel Worksheet Functions 1 July 18th 05 05:55 AM
Clear Contents - NonBold cells Steve Excel Discussion (Misc queries) 3 February 13th 05 11:36 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 0 November 7th 04 03:31 PM
Modify Row & Cell Contents based upon Cells Values bpat1434 Excel Worksheet Functions 1 November 7th 04 12:43 PM


All times are GMT +1. The time now is 10:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"