View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Make Worksheets Given a Certain YEAR

I don't understand why it would break at this command because all it's doing
is putting the date of the worksheet being currently created in the status
bar.

I'd simply delete the line because the date is only there fleetingly and
serves no purpose within the macro other than to slow it down while it's
adding the 365 worksheets.

Mike

"el zorro" wrote:

I copied this macro from one of the e-mail correspondences but somehow when I
run same it errors out with "sub or function not defined".

This macro is suppose to create worksheets given a certain YEAR.

The debugger is stopping at the "Application.StatusBar = D"

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


Thanks.