Is there a way to switch data between two cells?

G

Guest

I just want to be able to select two cells and have the data switch between
them without having to Cut, Copy or Paste.
 
G

Guest

Enter this macro:

Sub swap_it()
Dim r, r1, r2 As Range
If Selection.Count = 2 Then
i = 1
For Each r In Selection
If i = 1 Then
Set r1 = r
Else
Set r2 = r
End If
i = 2
Next
v1 = r1.Value
v2 = r2.Value
t = v1
r1.Value = v2
r2.Value = t
End If
End Sub

Then select two cells and run the macro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top