![]() |
error
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 |
error
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? -- - K Dales "Ray A" wrote: 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 |
All times are GMT +1. The time now is 12:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com