473,408 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Create 12 worksheets named after each month

33
Guys this pretty straight forward. I have a code that generates only the first three worksheets and names them after the first 3 months. I want to extend it to include all 12 months.

Here's my code:

Expand|Select|Wrap|Line Numbers
  1. Sub Mnth()
  2. Dim i As Integer
  3. For i = 1 To ActiveWorkbook.Sheets.Count
  4.    Sheets(i).Name = MonthName(i)
  5. Next
  6. End Sub
  7.  
Oct 16 '08 #1
2 2863
owuraku
33
Dont bother y'all. Figured it out!
Oct 16 '08 #2
GazMathias
228 Expert 128KB
Dont bother y'all. Figured it out!
Its always nice to see a solution to a problem.

Anywho, I came up with this:

Expand|Select|Wrap|Line Numbers
  1. Sub createbooks()
  2. Dim x As Integer
  3. Dim i As Integer
  4.  
  5. For i = 1 To 11
  6. If i = ActiveWorkbook.Sheets.Count Then
  7.      ActiveWorkbook.Sheets.Add
  8.     End If
  9. Next
  10.  
  11. For x = 1 To ActiveWorkbook.Sheets.Count
  12.    Sheets(x).Name = MonthName(x)
  13. Next
  14. End Sub
Would be nice to get that in one loop, but I figure this is better as it takes advantage of the way Excel inserts a sheet before the current one.

The first For loop only goes to eleven, because a workbook must contain at least one visible worksheet.

Gaz.
Oct 16 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ken Fine | last post by:
I want my application to maintain a directory tree based on months and years, e.g.: 2004 January file file file February file
1
by: Brian Johnson | last post by:
I am trying to create multiple (named) worksheets in excel using .Net PIA's. I have successfully created an excel document and set cell values, but have been unable to manipulate which worksheet...
1
by: poohnie08 | last post by:
i have a excel spreadsheet showing staff name, date,work hour, ot hour, slot1, slot2, slot3, slot4 and others). The "()" will keep repeating from day 1 until end of month. eg in excel spreadsheet,...
18
by: PC Datasheet | last post by:
An Access user saw my name in a newsgroup and sent me a request for help on a project. As part of the project, a list of the dates in a month was needed. For anyone needing a list of dates in a...
4
by: paul.chae | last post by:
I have a table in Access with about 3000 records. There are ~60 unique values in the ID field for the 3000 records. What I would like to do is automatically generate multiple Excel worksheets...
4
by: Abdhul Saleem | last post by:
Hi, I am recieving error ActiveX component can't create object in the following line in the asp page. set ExcelApp = CreateObject("Excel.Application") Previously this code was working fine....
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
2
by: cbs81 | last post by:
hi all, problem: transferring data from workbooks that are stored in a particular directory from excel to a table in access. when done, the workbooks that have been processed are automatically...
1
by: sudhaMurugesan | last post by:
Hi all, I 've created an xsl file to create an excel Workbook with multiple worksheets, thro' xslt. My code works fine for sheet1. Sheet2 was created but has no data. So please help me to fill...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.