Easier way to insert columns
Maybe overkill but this might help if you need to run it again on other
worksheets/books:
Best regards
John
Sub Check()
Dim sLabel As String
Columns("A:AN").Select '40 columns wide
Selection.Insert Shift:=xlToRight
Range("A1").Select
For x = 1 To 40
Select Case x
Case 1
sLabel = "Status"
Case 2
sLabel = "Details"
Case 3
sLabel = "Something Else...."
'Keep adding your labels here 1 to 40
End Select
Application.ActiveWorkbook.ActiveSheet.Cells(1, x).FormulaR1C1 =
sLabel
sLabel = ""
Next x
End Sub
"sanj" wrote in message
...
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
|