starsky
07-21-2009, 07:46 AM
I'm trying to apply some very basic code to all the worksheets in a book, but the macro just won't work. I use an almost idenitical process elsewhere without problem.
It will only apply code to the active ws, and creates too many new columns (I just want 1).
Sub LoopThroughSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Range("D1:E1").Select
Selection.AutoFill Destination:=Range("C1:E1"), Type:=xlFillDefault
Range("C2").Select
On Error Resume Next
Next ws
End Sub
Any help appreciated.
Thanks
It will only apply code to the active ws, and creates too many new columns (I just want 1).
Sub LoopThroughSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Range("D1:E1").Select
Selection.AutoFill Destination:=Range("C1:E1"), Type:=xlFillDefault
Range("C2").Select
On Error Resume Next
Next ws
End Sub
Any help appreciated.
Thanks