Consulting

Results 1 to 3 of 3

Thread: Inserting a new Column

  1. #1

    Post Inserting a new Column

    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
    Last edited by Eva_Johansso; 12-15-2013 at 01:10 PM.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Do you just need to qualify the workbook?

    Workbooks("Data").Worksheets("yoursheetname").Columns("AC").Insert Shift:=xlToRight
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Hi!

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

    BR

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •