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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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