error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to automate the opening of a workbook add 12 sheets and name each
of them for a month of the year.
This is the code and it does not work. Can someone help? Please feel free to
criticize as I am very new to VBA

Sub SheetsPerMonth()
Dim nwb As Workbook
Dim ShinWb As Integer
Dim newShinWb As Integer
Dim a As Integer
ShinWb = Application.SheetsInNewWorkbook
newShinWb = 12
Application.SheetsInNewWorkbook = newShinWb
Set nwb = Workbooks.Add
Application.SheetsInNewWorkbook = ShinWb
For a = 1 To 12
nwb.Sheets(a).Name = Format(DateSerial(2006, a, 1), "mmm")
Next
End Sub

TIA
 
Your code worked just fine for me (Excel 2000 on Win 2000). What is going
wrong? Are you getting an error message? If so, what is the error
number/description and which line of code is giving the error?
 
Back
Top