Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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" wrote in message ... 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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" wrote in message ... 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 ... 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" wrote in message ... 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Introduce Value in a cell with formula, option | Excel Discussion (Misc queries) | |||
Introduce decimal point in a list of values in column. | Excel Discussion (Misc queries) | |||
please introduce sorting by colors in excel | Excel Discussion (Misc queries) | |||
please introduce sorting by colors in excel | Excel Discussion (Misc queries) |