+ Reply to Thread
Results 1 to 5 of 5

Introduce new column using VBA macros

  1. #1
    Swamy
    Guest

    Introduce new column using VBA macros

    Hi,

    I have 6 columns already in my Excel document. How can i insert a column
    between 4 and 5 using VBA macros?

    Thanks for your help.

    Swamy

  2. #2
    Karthik Bhat - Bangalore
    Guest

    Re: Introduce new column using VBA macros

    Hi Swamy

    This code should work assuming that your first column is "A" (if not
    change the column number in the code appropriately.

    Sub InsertColumn()
    Columns("E:E").Select
    Selection.Insert Shift:=xlToRight
    End Sub

    Thanks and Regards
    Karthik Bhat
    Bangalore


  3. #3
    Peter T
    Guest

    Re: Introduce new column using VBA macros

    Hi Swamy,

    If you record a macro -

    Columns("E:J").Select
    Selection.Insert Shift:=xlToRight

    But as recording macros also record unnecessary key strokes like selecting
    cells or, in this case, columns, it can be simplified -

    Sub InsertColumns()

    Columns("E:J").Insert Shift:=xlToRight

    End Sub

    This assumes of course you want to insert 6 columns between D & E.

    Regards,
    Peter T

    "Swamy" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I have 6 columns already in my Excel document. How can i insert a column
    > between 4 and 5 using VBA macros?
    >
    > Thanks for your help.
    >
    > Swamy




  4. #4
    Dana DeLouis
    Guest

    Re: Introduce new column using VBA macros

    > How can i insert a column
    > between 4 and 5 using VBA macros?


    Hi.
    Columns(5).Insert

    HTH. :>)
    --
    Dana DeLouis
    Win XP & Office 2003


    "Swamy" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I have 6 columns already in my Excel document. How can i insert a column
    > between 4 and 5 using VBA macros?
    >
    > Thanks for your help.
    >
    > Swamy




  5. #5
    Peter T
    Guest

    Re: Introduce new column using VBA macros

    Er - somehow (how!) I read you wanted to insert 6 columns. Ignore my
    previous and go with Dana's, or
    Columns("E").Insert

    Regards,
    Peter T

    "Peter T" <peter_t@discussions> wrote in message
    news:ermSwfY#[email protected]...
    > Hi Swamy,
    >
    > If you record a macro -
    >
    > Columns("E:J").Select
    > Selection.Insert Shift:=xlToRight
    >
    > But as recording macros also record unnecessary key strokes like selecting
    > cells or, in this case, columns, it can be simplified -
    >
    > Sub InsertColumns()
    >
    > Columns("E:J").Insert Shift:=xlToRight
    >
    > End Sub
    >
    > This assumes of course you want to insert 6 columns between D & E.
    >
    > Regards,
    > Peter T
    >
    > "Swamy" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > >
    > > I have 6 columns already in my Excel document. How can i insert a

    column
    > > between 4 and 5 using VBA macros?
    > >
    > > Thanks for your help.
    > >
    > > Swamy

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1