How do I copy a worksheet for each day of the year?
Got it! This is what I did:
Sub MakeMonth()
Dim SH As Worksheet
Dim myDate As Variant
Dim D As Date, Y As Long
Set SH = ActiveSheet
myDate = InputBox(Prompt:="Enter the first day of the Month you want to
Create", _
Default:=Format(Date, "mm/dd/yy"))
'If Y < 2000 Then Exit Sub
'If Y 2100 Then Exit Sub
Application.ScreenUpdating = False
myDate = CDate(myDate)
'For D = DateSerial(Y, 1, 1) To DateSerial(Y, 12, 31)
For iCtr = DateSerial(Year(myDate), Month(myDate), 1) To
DateSerial(Year(myDate), Month(myDate) + 1, 0)
Application.StatusBar = D
SH.Copy after:=Sheets(Sheets.Count)
'ActiveSheet.Range("A1").Value = D
ActiveSheet.Name = Format(iCtr, "dddd mm-dd")
Next
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
Thanks again for the initial code!
"Harald Staff" wrote:
Glad it worked for you Kay.
(Your boss will understand that a job like that would take at least 2-3 long
unpaid evenings, and buy you an expensive dinner :-)
Best wishes Harald
"Kaybay" skrev i melding
...
Hi Harold,
It's like magic!
Thank you very much. I really appreciate the help.
Kay
"Harald Staff" wrote:
Hi
Run this littme macro when your master sheet is the active sheet:
Sub MakeYear()
Dim SH As Worksheet
Dim D As Date, Y As Long
Set SH = ActiveSheet
Y = Val(InputBox("Year:"))
If Y < 2000 Then Exit Sub
If Y 2100 Then Exit Sub
Application.ScreenUpdating = False
For D = DateSerial(Y, 1, 1) To DateSerial(Y, 12, 31)
Application.StatusBar = D
SH.Copy after:=Sheets(Sheets.Count)
ActiveSheet.Range("A1").Value = D
ActiveSheet.Name = Format(D, "mmm dd")
Next
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
HTH. best wishes Harald
"Kaybay" skrev i melding
...
I'm trying to create a new sheet for each day of the year. It needs
to
contain the day and date but I really don't want to copy and paste 2
years
of
forms and manually change the date. Please can anybody help.
|