Hi i have a workbook with 21 worksheet.
i was trying to write a macro that would add a column at the beginning of each sheet with the name of the month entered by the user.
Here is my code, i don't know what is wrong with it but all i does is add 21 new column in sheet 1.
i was trying to write a macro that would add a column at the beginning of each sheet with the name of the month entered by the user.
Here is my code, i don't know what is wrong with it but all i does is add 21 new column in sheet 1.
Code:
Sub Month ()
' ask user for month name
Dim monthName As String
monthName = InputBox(Prompt:="What Month", _
Title:="Please entre name of the month", Default:="January 2013")
' insert a column
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Worksheets
Columns("A:A").Insert Shift:=xlToLeft, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Value = monthName
Next sht
End Sub