PDA

View Full Version : [SOLVED] Inserting a new Column



Eva_Johansso
12-15-2013, 12:36 PM
I want to insert a new columns in my worksheet somewhere in the middle of other columns using VBA through button click event
for instance I have columns from A to AC and now want to insert a new column just before AC and the new column will take the place of AC and actual AC would be move to AD and so on if there are other columns in the sheet?

Old sheet columns -> A, B, C, D....... up to AC
New sheet Columns -> A, B, C, D..... up to AC and AD ... and so on if existed (AC is the new column inserted) which happens to push the previous AC to AD and AD to AE and so on

The button is on the one workbook and inserting columns suppose to take place on the other worksheet of a workbook

here is my attempt


Sheets("yoursheetname").Columns("AC").Insert Shift:=xlToRight


I have two workbooks
1. Main
2. Data

Button and the code is on the Main workbook
and adding columns is taking place in the Data Workbook

any Idea?

Thanks for your help
BR

Bob Phillips
12-15-2013, 04:50 PM
Do you just need to qualify the workbook?


Workbooks("Data").Worksheets("yoursheetname").Columns("AC").Insert Shift:=xlToRight

Eva_Johansso
12-16-2013, 09:34 AM
Hi!

Yes copy and paste worked and so did your codeo... thanks for your help

BR