On open select worksheet by day of month

  • Thread starter Thread starter sylv1501
  • Start date Start date
S

sylv1501

I have a workbook with sheets numbered 1-31 for each day of the month.
How can I program this to open on the sheet for the current day?
 
Use the workbook open event in the ThisWorkbook module.
Convert today's date to a string and use that as the workbook name.
'--
Private Sub Workbook_Open()
ThisWorkbook.Worksheets(CStr(Day(Date))).Select
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




<[email protected]>
wrote in message
I have a workbook with sheets numbered 1-31 for each day of the month.
How can I program this to open on the sheet for the current day?
 
Option Explicit
sub Auto_Open()

on error resume next 'just in case
application.goto worksheets(cstr(day(date))).range("a1"), scroll:=true
if err.number <> 0 then
beep 'failed
error.clear
end if
end sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Place this in the workbook open section
Worksheets(Format(Date, "dd")).Activate
Best wishes
Graham F
 
"and use that as the workbook name"

should read

"and use that as the worksheet name"
 
I have a workbook with sheets numbered 1-31 for each day of the month.
How can I program this to open on the sheet for the current day?

Place this in "ThisWorkbook"

Private Sub Workbook_Open()
Dim DayOfMonth As String
DayOfMonth = Day(Now())
Worksheets(DayOfMonth).Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top