How can I swap cells

J

Josh W

What is the quickest way to swap two different cells. Say I want to move the
contents of cell A5 to cell D9 and the contents of cell D9 back to A5 -
basically swapping the two. Thanks.
 
S

Sheeloo

Not sure what you are looking for...

Cut (or copy) and paste A5 to an empty cell, cut (or copy) and paste D9 to
A5, cut (or copy) from the cell you coped A5 and paste to D9... Clear the
cell used.
 
J

Josh W

Thanks, but I knew that already. However, to swap the contents with cut and
paste is extremely tedious, especially as I have to do it quite often. I want
to know if there is any shortcut/button/macro? I just noticed some
discussions about this from a few years back. But I don't know anything about
macro's so I wouldn't know I to create the button myself. Greatly appreciate
any help..
 
S

Shane Devenshire

Hi,

This code swaps two selected cells

Sub Swap()
Y = Selection.Areas(1)
Selection.Areas(1) = Selection.Areas(2)
Selection.Areas(2) = Y
End Sub

If this helps, please click the Yes button
 
J

Josh W

Shane, the macro works perfectly. You saved me.

Shane Devenshire said:
Hi,

This code swaps two selected cells

Sub Swap()
Y = Selection.Areas(1)
Selection.Areas(1) = Selection.Areas(2)
Selection.Areas(2) = Y
End Sub

If this helps, please click the Yes button

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire
 
J

Josh W

Sheelo, I used Shane's macro because that macro is a swap command for all two
cells selected, which is extremely useful. Your link to setting up macro's
was excellent. I did it the first time today. Thanks.
 

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

Similar Threads


Top