ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to create the new worksheets. (https://www.excelbanter.com/excel-programming/326923-macro-create-new-worksheets.html)

Houm[_2_]

Macro to create the new worksheets.
 

I got a worksheet that include the current Month, date ,
weekday and year. How do I create the macro to run that
create the new worksheets accordingly to the days of the
current months? Examples there's 30 days of the month of
april. It will generated and create 30 worksheets?

JulieD

Macro to create the new worksheets.
 
Hi Huom

hopefully, i've understood what you want - here's some code that will create
a sheet for each day of the current month .. and number them from 1 to
whatever the last day of the month is ...
----
Sub createsheets()
If MsgBox("Are you very very sure you want to do this?", vbYesNo,
"Create LOTS of Sheets") = vbYes Then
For i = 1 To Day(DateSerial(Year(Date), Month(Date) + 1, 0))
Worksheets.Add Befo=Worksheets(Worksheets.Count)
ActiveSheet.Name = i
Next
End If
End Sub
----

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"Houm" wrote in message
...

I got a worksheet that include the current Month, date ,
weekday and year. How do I create the macro to run that
create the new worksheets accordingly to the days of the
current months? Examples there's 30 days of the month of
april. It will generated and create 30 worksheets?




Huom

Macro to create the new worksheets.
 
Thank you very much. Yah, it does creat many sheets as
per month. But, I also would like the Month, Date,Weekday
and year cells copy to all the new sheets that just been
creat. The Date and weekday will increment by 1 to all the
sheets.

Examples: The default sheet has Month = April, Date=
05, weekday = Tuesday and year = 2005. The second sheet's
date, weekday will be increse by one and next sheet so
on...


-----Original Message-----
Hi Huom

hopefully, i've understood what you want - here's some

code that will create
a sheet for each day of the current month .. and number

them from 1 to
whatever the last day of the month is ...
----
Sub createsheets()
If MsgBox("Are you very very sure you want to do

this?", vbYesNo,
"Create LOTS of Sheets") = vbYes Then
For i = 1 To Day(DateSerial(Year(Date), Month

(Date) + 1, 0))
Worksheets.Add Befo=Worksheets

(Worksheets.Count)
ActiveSheet.Name = i
Next
End If
End Sub
----

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"Houm" wrote in message
...

I got a worksheet that include the current Month,

date ,
weekday and year. How do I create the macro to run that
create the new worksheets accordingly to the days of the
current months? Examples there's 30 days of the month of
april. It will generated and create 30 worksheets?



.


JulieD

Macro to create the new worksheets.
 
Hi Huom

okay, assuming the sheet you've set up is called sheet1 and the date cell is
C1
(base the Weekday cell on the date cell so it will change automatically) the
following should do what you want.

---
Sub createsheets()
If MsgBox("Are you very very sure you want to do this?", vbYesNo,
"Create LOTS of Sheets") = vbYes Then
For i = 1 To Day(DateSerial(Year(Date), Month(Date) + 1, 0))
Sheets("Sheet1").Copy Befo=Worksheets(Worksheets.Count)
ActiveSheet.Name = i
Range("C1").Value = i
Next
End If
End Sub
---

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"Huom" wrote in message
...
Thank you very much. Yah, it does creat many sheets as
per month. But, I also would like the Month, Date,Weekday
and year cells copy to all the new sheets that just been
creat. The Date and weekday will increment by 1 to all the
sheets.

Examples: The default sheet has Month = April, Date=
05, weekday = Tuesday and year = 2005. The second sheet's
date, weekday will be increse by one and next sheet so
on...


-----Original Message-----
Hi Huom

hopefully, i've understood what you want - here's some

code that will create
a sheet for each day of the current month .. and number

them from 1 to
whatever the last day of the month is ...
----
Sub createsheets()
If MsgBox("Are you very very sure you want to do

this?", vbYesNo,
"Create LOTS of Sheets") = vbYes Then
For i = 1 To Day(DateSerial(Year(Date), Month

(Date) + 1, 0))
Worksheets.Add Befo=Worksheets

(Worksheets.Count)
ActiveSheet.Name = i
Next
End If
End Sub
----

--
Cheers
JulieD
check out www.hcts.net.au/tipsandtricks.htm
....well i'm working on it anyway
"Houm" wrote in message
...

I got a worksheet that include the current Month,

date ,
weekday and year. How do I create the macro to run that
create the new worksheets accordingly to the days of the
current months? Examples there's 30 days of the month of
april. It will generated and create 30 worksheets?



.





All times are GMT +1. The time now is 07:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com