View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_4_] Jim Thomlinson[_4_] is offline
external usenet poster
 
Posts: 1,119
Default Easier way to insert columns

You can get rid of the selects...

Columns("A:A").Insert Shift:=xlToRight
Range("A1").Formula = "Status"
Columns("C:C").Insert Shift:=xlToRight
Range("C1").Formula = "Details"

--
HTH...

Jim Thomlinson


"sanj" wrote:

Hi,

I need to insert 40-50 columns and label the headers, at the moment I am
using the following code in a macro:

Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select
ActiveCell.FormulaR1C1 = "Status"
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Range("C1").Select
ActiveCell.FormulaR1C1 = "Details"

etc

Is there an easier way to write this?

Thanks!

Excel 2002