Hi,
My excel VBA experience is limited. I have a sheet that includes a list of columns that can be inserted to another "Main Page " sheet. I am trying to add the columns to the right of the existing columns in the "Main Page" Sheet through a Button. The button code is as following:
(
Sheets("Insert Variable").Select
Range("C1:D24").Select
Selection.Copy
Sheets("Main Page").Select
Columns("C:D").Select
Selection.Insert Shift:=xlToRight
Application.CutCopyMode = False)
It works but adds always adds the columns into the (column C and D) which makes it add it to the left of the existing ones. This messes up the absolute references.
Can you advise how to amend the code to make the insert button add columns to the right of the existing columns ?
Thanks
My excel VBA experience is limited. I have a sheet that includes a list of columns that can be inserted to another "Main Page " sheet. I am trying to add the columns to the right of the existing columns in the "Main Page" Sheet through a Button. The button code is as following:
(
Sheets("Insert Variable").Select
Range("C1:D24").Select
Selection.Copy
Sheets("Main Page").Select
Columns("C:D").Select
Selection.Insert Shift:=xlToRight
Application.CutCopyMode = False)
It works but adds always adds the columns into the (column C and D) which makes it add it to the left of the existing ones. This messes up the absolute references.
Can you advise how to amend the code to make the insert button add columns to the right of the existing columns ?
Thanks