Swap pasting - cutting and pasting cells' contents

funguy

New Member
Joined
Feb 7, 2012
Messages
24
I'm doing a ton of corrections for mixed up information. Is there a function that will cut and paste a cell's contents and automatically push the destination's cells contents to the original cell that you cut from? i.e. - Swapping contents...

if that does exists, I'd assume I could assign a custom keyboard shortcut to the task. Any ideas would be great . thanks !
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
This is a very nice idea and very handy:)

Insert a Module and copy the below code to its code window.

You can then assign shortcut keys to SourceCell and DestinationCell.
Code:
[FONT="Consolas"][SIZE="2"][COLOR="Navy"]Option Explicit

Sub SourceCell()
    ActiveWorkbook.Names.Add Name:="SourceCell", RefersTo:="=" & ActiveCell.Address
End Sub

Sub DestinationCell_Swap()

    Dim vSwap As Variant

    vSwap = ActiveCell.Value
    On Error Resume Next
    ActiveCell = Range(ActiveWorkbook.Names("SourceCell").RefersTo).Value
    If Err.Number <> 0 Then
        On Error GoTo 0
        Exit Sub
    End If

    On Error GoTo 0
    Range(ActiveWorkbook.Names("SourceCell").RefersTo).Value = vSwap
    ActiveWorkbook.Names("SourceCell").Delete

End Sub[/COLOR][/SIZE][/FONT]
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top