Consulting

Results 1 to 2 of 2

Thread: Inserting columns using VBA

  1. #1
    VBAX Newbie
    Joined
    Apr 2012
    Posts
    2
    Location

    Inserting columns using VBA

    I have a lot of tables of information on one worksheet. Each table is separated by an empty column. I need to be able to write a code that will insert an extra column between each table. All tables are 8 columns wide and use 50 rows. Can anyone help please?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    Off the top

    [vba]
    With Activesheet

    lastcol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    For i = lastcol - 8 to 9 Step -1

    .Columns(i).Insert
    Next i
    End With[/vba]
    ____________________________________________
    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

Posting Permissions

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