Open worksheet according to time and date

wgibcus

New Member
Joined
Aug 26, 2009
Messages
5
I have a workbook that teachers use to mark attendance for their class each day. There are two worksheets for each month - one for morning and one for afternoon (named Jan AM and Jan PM, Feb AM and Feb PM etc). The morning attendance sheet automatically updates the afternoon sheet with each student's status so that afternoon attendance is easier to mark (it is a legal requirement that the roll be marked twice a day). The problem is that some teachers forget to switch back to the morning worksheet the next day, because Excel remembers the last worksheet, and then they update the afternoon worksheet by mistake.

I would like to know how to use VB to calculate the month and the time (morning or afternoon) and have Excel open with the appropriate worksheet. I'm guessing it would be a variation of

Private Sub Workbook_Open()
Worksheets("Jan AM").Activate
End Sub

which currently opens the January morning attendance worksheet when Excel opens.

Any help is gratefully appreciated.

Waynos
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try

Code:
Worksheets(Format(Date, "mmm") & " " & IIf(Time > 0.5, "PM", "AM")).Activate
 
Upvote 0

Forum statistics

Threads
1,215,032
Messages
6,122,770
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top