Copy last two columns and insert to the right of them

absherzad

New Member
Joined
Jun 19, 2017
Messages
42
Greetings.

I am having trouble being able to copy the last two columns with data in a worksheet and then insert the same columns to the right of them. Here is my code so far, it does not work because the top row is merge of more columns. Here is the
iATSMoC.png
is the screenshot link.

Code:
Sub newTest()
    Columns("I:J").Select
    Range("I:J").Select
    Selection.Copy
    Selection.Insert Shift:=xlToRight
End Sub
iATSMoC.png
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
The following code works. However, it does not insert the columns instead it overrides the next columns.

Code:
Columns("I:J").EntireColumn.Copy ActiveCell.Offset(0, 1).EntireColumn
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,217
Members
452,619
Latest member
Shiv1198

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