#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: "Excel encountered an error and had to remove some formatti Carl Excel Discussion (Misc queries) 0 September 18th 06 06:39 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM


All times are GMT +1. The time now is 03:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"