View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Open to today's date

This code will open the correct sheet for the current week. You need to
modify the code to match your sheet names. The code uses Sunday as the 1st
day of the week. The 1st week of the year can have less than 7 days if the
year doesn't start on a Sunday.

Private Sub App_WorkbookOpen(ByVal Wb As Workbook)

Jan1 = DateSerial(Year(Date), 1, 1)
DayofWeek = Weekday(Jan1)
FirstSunday = Jan1 - DayofWeek + 1 'Sunday may be inprevious year

Weeknumber = Int((Date - FirstSunday) / 7)
SheetName = "Week_" '<=modify to match your sheet names
Worksheets(SheetName & Weeknumber).Activate
End Sub

"KathyN" wrote:

Hello

I have a workbook with a sheet for each week of the year. The dates are in
the same row in each sheet. I would like to be able to have the workbook
open to the sheet that contains today's date.

Thanks for your help!