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
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
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
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
> 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
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
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks