Activate today's sheet

Martin_H

Board Regular
Joined
Aug 26, 2020
Messages
190
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have workbook with 5 worksheets in it. Sheets are named Monday, Tuesday, Wednesday, Thursday and Friday.

I want Excel to activate today's sheet on Workbook open procedure.

So basicaly if it's Monday today, Excel will activate sheet called Monday. If it's Tuesday today, Excel will activate sheet called Tuesday.

If it's Saturday or Sunday, then activate Monday.

Thank you for help. Much appreciated.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Maybe this very basic code is doing the job
VBA Code:
Private Sub Workbook_Open()
i = Weekday(Date, vbUseSystemDayOfWeek)
Sheets(i).Select
End Sub
 
Upvote 0
Maybe this very basic code is doing the job
VBA Code:
Private Sub Workbook_Open()
i = Weekday(Date, vbUseSystemDayOfWeek)
Sheets(i).Select
End Sub
Hi GraH, thank you for your reply.

I used this instead:

VBA Code:
Private Sub Workbook_Open()
Select Case Weekday(Date, vbMonday)
Case 1
Worksheets("Monday").Select
Case 2
Worksheets("Tuesday").Select
Case 3
Worksheets("Wednesday").Select
Case 4
Worksheets("Thursday").Select
Case 5
Worksheets("Friday").Select
Case 6
Worksheets("Monday").Select
Case 7
Worksheets("Monday").Select
End Select
End Sub
 
Upvote 0
Solution
You can slim that down slightly like
VBA Code:
Private Sub Workbook_Open()
Select Case Weekday(Date, vbMonday)
Case 1, 6, 7
Worksheets("Monday").Select
Case 2
Worksheets("Tuesday").Select
Case 3
Worksheets("Wednesday").Select
Case 4
Worksheets("Thursday").Select
Case 5
Worksheets("Friday").Select
End Select
End Sub
 
Upvote 0
I have workbook with 5 worksheets in it. Sheets are named Monday, Tuesday, Wednesday, Thursday and Friday.
Assuming the 5 sheets are in that order, try
VBA Code:
Private Sub Workbook_Open()
  Sheets(Application.Max(Weekday(Date, vbSaturday) - 2, 1)).Activate
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,756
Messages
6,126,692
Members
449,330
Latest member
ThatGuyCap

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