switch 2 cells around

  • Thread starter Thread starter whitedevil
  • Start date Start date
W

whitedevil

Is there a way to switch two cells around? Copy something from cell A t
cell B and from B to A without using any extra empty cells. Maybe usin
some function?

Thanks
 
Hi!

Not to my knowledge.
VBA could do it: sample swap of ranges below:

Sub Swap(a As Range, b As Range)
If a.Count <> b.Count Then Exit Sub
If a.Rows.Count <> b.Rows.Count Then Exit Sub

Dim c As Variant
c = a.Formula
a.Formula = b.Formula
b.Formula = c

End Sub

Could be called by a commandbutton which connected to a sub like

Private Sub CommandButton1_Click()
Swap Range("E4:E7"), Range("F4:F7")
End Sub

In this configuration, it would of course toggle the two ranges.

Al
 

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

Back
Top