View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Doug Glancy Doug Glancy is offline
external usenet poster
 
Posts: 770
Default Rename Worksheets to Sequential Dates

This assumes that you have just one sheet in your workbook before you start
and you want it to be the "1-Jan" sheet:

Sub test()

Dim I As Long
Dim sheet_date As Date

Application.ScreenUpdating = False
'On Error GoTo err_handler

sheet_date = #1/1/2004#
ThisWorkbook.Worksheets(1).Name = Day(sheet_date) & "-" &
Format((sheet_date), "mmm")

For I = 1 To 365
sheet_date = sheet_date + 1
ThisWorkbook.Worksheets.Add ,
AFTER:=ThisWorkbook.Worksheets(ThisWorkbook.Worksh eets.Count)
ActiveSheet.Name = Day(sheet_date) & "-" & Format((sheet_date), "mmm")
Next I

err_handler:
Application.ScreenUpdating = True

End Sub

hth,

Doug Glancy

"nchristus " wrote in message
...
I want to create a workbook with 366 worksheets each named for a day of
the year (1-Jan,2-Jan,3-Jan...).

Is there VBA code that will create worksheets and rename them using
days of the year?

Thanks.


---
Message posted from http://www.ExcelForum.com/