Copy and paste non-contiguous cells in same position

Jeff131313

New Member
Joined
Feb 9, 2011
Messages
32
I want to paste a group of non-contiguous cells, and paste the values elsewhere on the sheet while maintaining the same relative position. is this possible via macro somehow?

for example, in column A i want to copy A1,A2,A5,A9; and paste into D1,D2,D5,D9 in one step.

thanks in advance!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Code:
    Dim rArea As Range

    
    For Each rArea In Range("A1,A2,A5,A9").Areas
        rArea.Copy rArea.Offset(, 3)
    Next rArea
 
Upvote 0
i'm sorry but I am not extremely familiar with VBA code. could you please type the entire code for the above scenario, or help elaborate on the step by step details.

thank you in advance!
 
Upvote 0
Code:
Sub Jeff()
    Dim rArea As Range

    For Each rArea In Range("A1,A2,A5,A9").Areas
        rArea.Copy rArea.Offset(, 3)
    Next rArea
End Sub
 
Upvote 0
this macro only will work once, and assumes I only want to paste 3 colums to the right. do you know if it is possible to have a dynamic macro that will work if I select column A and want to paste into column T or any other column that may not only be an offset of 3 like you have in the macro?
 
Upvote 0
How would the macro know where you want to paste the values?
 
Upvote 0
I was thinking of copying the non-contiguous cells, then selecting the first cell i want to paste into, and using a macro button to paste from current selected cell. would that work?
 
Upvote 0
OK ...

Code:
Sub Jeff()
    Dim rArea As Range
    Dim sCol As String

    sCol = InputBox("Enter the column letter(s) to paste to")
    
    For Each rArea In Selection.Areas
        rArea.Copy Intersect(rArea.EntireRow, Columns(sCol))
    Next rArea
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,823
Messages
6,121,780
Members
449,049
Latest member
greyangel23

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