ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How can I swap cells (https://www.excelbanter.com/excel-discussion-misc-queries/223741-how-can-i-swap-cells.html)

Josh W

How can I swap cells
 
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.

Sheeloo[_3_]

How can I swap cells
 
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.

"Josh W" wrote:

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.


Josh W

How can I swap cells
 
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..

"Sheeloo" wrote:

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.

"Josh W" wrote:

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.


Sheeloo[_3_]

How can I swap cells
 
Following macro will do the swap for you
Sub swap()
temp = Cells(5, 1)
Cells(5, 1) = Cells(9, 4)
Cells(9, 4) = temp
End Sub

See http://www.taltech.com/support/sw_tricks/exmacros.htm on details on how
to use a macro

"Josh W" wrote:

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..

"Sheeloo" wrote:

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.

"Josh W" wrote:

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.


Shane Devenshire

How can I swap cells
 
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


"Josh W" wrote:

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..

"Sheeloo" wrote:

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.

"Josh W" wrote:

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.


Josh W

How can I swap cells
 
Shane, the macro works perfectly. You saved me.

"Shane Devenshire" wrote:

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


"Josh W" wrote:

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..

"Sheeloo" wrote:

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.

"Josh W" wrote:

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.


Josh W

How can I swap cells
 
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.

"Sheeloo" wrote:

Following macro will do the swap for you
Sub swap()
temp = Cells(5, 1)
Cells(5, 1) = Cells(9, 4)
Cells(9, 4) = temp
End Sub

See http://www.taltech.com/support/sw_tricks/exmacros.htm on details on how
to use a macro

"Josh W" wrote:

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..

"Sheeloo" wrote:

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.

"Josh W" wrote:

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.



All times are GMT +1. The time now is 12:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com