Can I swap cell info?

listerheb

Active Member
Joined
Aug 22, 2003
Messages
262
I constantly have to swap content from a group of five cells with another group of five cells. What I have been doing is copying from the first five to a blank five, then taking the second five and copying it to the first, then moving the one I moved at the begining to the second set of five, and finally deleting the left over. Is there a way to select both sets and swap the contents? I must do this over a hundred times in a day.
 
Not knowing the context in which the worksheet has been created and not knowing the background of why you are swapping the cell values, and so forth, I can not comment about the suitability of your layout -- however, in reference to your latest specification, try the following ...
Code:
Sub ySwap4()
    
    '**** two step process ....
    '* Step 1 ... select First range to swap e.g. Z7:AB9
    '****
    Set yRange = Selection
    Debug.Print yRange.Address
    Selection.Copy [[Personal.xls]sheet1!A1]
    
    '**** two step process ....
    '* Step 2 ... key-in cells of range to swap e.g. AH12:AJ14
    '****
    swapRange = InputBox("key-in SwapRange cells")
        Debug.Print swapRange
        Set SwapMe = Range(swapRange)
        SwapMe.Copy yRange
        [[Personal.xls]sheet1!A1:C3].Copy SwapMe
    
    '**** two step process ....
    '* All Done!
    '****
End Sub
Not to interfere with any of the cells in your worksheet, I am storing the value of the first cell to be swapped in cells A1:C3 of Sheet1 of the Personal Workbook -- if this is not feasible choose any other range for this purpose and make adjustments accordingly.
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,216,095
Messages
6,128,800
Members
449,468
Latest member
AGreen17

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