error

R

Ray A

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
 
K

K Dales

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top