Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default One for every month

I have created a worksheet that we need to copy and label January through
December, is tere a way to do this automatically?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default One for every month

Sub AddSheets()
Dim sh As Worksheet
Dim i As Long

With ActiveWorkbook

For i = 1 To 12
Set sh = .Worksheets.Add(after:=.Worksheets(.Worksheets.Cou nt))
sh.Name = Format(DateSerial(Year(Date), i, 1), "mmmm")
Next i
End With
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"DonV" wrote in message
...
I have created a worksheet that we need to copy and label January through
December, is tere a way to do this automatically?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default One for every month

Option Explicit
Sub testme()
Dim mCtr As Long
Dim MstrWks As Worksheet
Dim NewWks As Worksheet

Set MstrWks = Worksheets("master")

For mCtr = 12 To 1 Step -1
MstrWks.Copy _
after:=MstrWks
ActiveSheet.Name = Format(DateSerial(2008, mCtr, 1), "MMMM")
'or if you're using xl2002 or newer
'ActiveSheet.Name = MonthName(Month:=mCtr, abbreviate:=False)
Next mCtr
End Sub

DonV wrote:

I have created a worksheet that we need to copy and label January through
December, is tere a way to do this automatically?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default One for every month

dave:

just a little variant of your code as an example:

Sub name_sheets()
Dim i As Long
Dim wkcount As Long
Dim sh As Worksheet
wkcount = Worksheets.Count
For i = 1 To 12
With ActiveWorkbook
Set sh =
..Worksheets.Add(after:=.Worksheets(.Worksheets.Co unt))
ActiveSheet.Name = MonthName(Month:=ActiveSheet.Index -
wkcount, abbreviate:=True)
End With
Next
End Sub


--


Gary


"Dave Peterson" wrote in message
...
Option Explicit
Sub testme()
Dim mCtr As Long
Dim MstrWks As Worksheet
Dim NewWks As Worksheet

Set MstrWks = Worksheets("master")

For mCtr = 12 To 1 Step -1
MstrWks.Copy _
after:=MstrWks
ActiveSheet.Name = Format(DateSerial(2008, mCtr, 1), "MMMM")
'or if you're using xl2002 or newer
'ActiveSheet.Name = MonthName(Month:=mCtr, abbreviate:=False)
Next mCtr
End Sub

DonV wrote:

I have created a worksheet that we need to copy and label January through
December, is tere a way to do this automatically?


--

Dave Peterson



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default One for every month

This code worked thank you. However, is it possible to make it copy an
existing sheet and ues it to make the other sheets?

"Bob Phillips" wrote in message
...
Sub AddSheets()
Dim sh As Worksheet
Dim i As Long

With ActiveWorkbook

For i = 1 To 12
Set sh = .Worksheets.Add(after:=.Worksheets(.Worksheets.Cou nt))
sh.Name = Format(DateSerial(Year(Date), i, 1), "mmmm")
Next i
End With
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"DonV" wrote in message
...
I have created a worksheet that we need to copy and label January through
December, is tere a way to do this automatically?






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default One for every month

Sub AddSheets()
Dim sh As Worksheet
Dim i As Long

With ActiveWorkbook

Set sh = ActiveSheet
For i = 1 To 12
sh.Copy After:=.Worksheets(.Worksheets.Count)
ActiveSheet.Name = Format(DateSerial(Year(Date), i, 1), "mmmm")
Next i
End With
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"DonV" wrote in message
...
This code worked thank you. However, is it possible to make it copy an
existing sheet and ues it to make the other sheets?

"Bob Phillips" wrote in message
...
Sub AddSheets()
Dim sh As Worksheet
Dim i As Long

With ActiveWorkbook

For i = 1 To 12
Set sh =
.Worksheets.Add(after:=.Worksheets(.Worksheets.Cou nt))
sh.Name = Format(DateSerial(Year(Date), i, 1), "mmmm")
Next i
End With
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"DonV" wrote in message
...
I have created a worksheet that we need to copy and label January through
December, is tere a way to do this automatically?






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default One for every month

Thanks

"Bob Phillips" wrote in message
...
Sub AddSheets()
Dim sh As Worksheet
Dim i As Long

With ActiveWorkbook

Set sh = ActiveSheet
For i = 1 To 12
sh.Copy After:=.Worksheets(.Worksheets.Count)
ActiveSheet.Name = Format(DateSerial(Year(Date), i, 1), "mmmm")
Next i
End With
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"DonV" wrote in message
...
This code worked thank you. However, is it possible to make it copy an
existing sheet and ues it to make the other sheets?

"Bob Phillips" wrote in message
...
Sub AddSheets()
Dim sh As Worksheet
Dim i As Long

With ActiveWorkbook

For i = 1 To 12
Set sh =
.Worksheets.Add(after:=.Worksheets(.Worksheets.Cou nt))
sh.Name = Format(DateSerial(Year(Date), i, 1), "mmmm")
Next i
End With
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"DonV" wrote in message
...
I have created a worksheet that we need to copy and label January
through December, is tere a way to do this automatically?






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default One for every month

After creating the additional pages in my workbook and saving it the icon
for the workbook had a yellow overlay with an exclamation mark. Does this
mean that something is wrong with the workbook?

"DonV" wrote in message
...
I have created a worksheet that we need to copy and label January through
December, is tere a way to do this automatically?


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
excel to make the days cary over month to month automaticly GARY New Users to Excel 1 April 19th 08 06:05 PM
Excel 2003 month to month data change grid Chad[_2_] Excel Discussion (Misc queries) 2 February 15th 08 01:36 AM
When using MONTH function on Blank Cell!! Returns Month=Jan! mahou Excel Discussion (Misc queries) 6 January 9th 06 02:46 AM
copy worksheet from previous month and rename to current month Dan E. Excel Programming 4 December 8th 05 09:40 PM
transfer cell $ amount to other sheet month-to-month without overc Colin2u Excel Discussion (Misc queries) 1 July 28th 05 02:36 AM


All times are GMT +1. The time now is 04:29 PM.

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

About Us

"It's about Microsoft Excel"