I am trying to create an excel macro that automatically inserts two columns in front of column D ... This procedure worked fine when I created it, here it is:
Sub AddColumns()
Columns("D:D").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
End Sub
But when I open the worksheet and check it, all my data is shifted to the right for about 11 columns and 11 empty columns are added. I am sure this is due to some rows in which 11 columns are combined. Select statements select the first 11 columns of AK.
How to fix it?
source
share