Worksheets with dates on, automatically go to that day.

jonboy79

New Member
Joined
Apr 25, 2018
Messages
2
So i'm looking for some code to go to the day of my workbook. Each worksheet is dated 1,2,3,4,5 and so on. But when i open program i would like it to go straight to that day i.e, straight to that worksheet, as i've sometimes forgot to change day!!

Regards
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
If the sheets really are numbered 1..31 then this would go to the current day sheet when you open the workbook. Alt+F11 to bring up the VBA Editor, double-click the "ThisWorkbook" module and paste the following:

Code:
Private Sub Workbook_Open()


Sheets(Format(Date, "d")).Activate


End Sub

WBD
 
Upvote 0
I do apologize, labeled 1st, 2nd, 3rd. Thank you for you quick response and sorry for not responding sooner been stuck in bed.
 
Upvote 0
OK. give this a go.

Code:
Private Sub Workbook_Open()

Dim sheetName As String

Select Case Day(Date)
    Case 1, 21, 31
        sheetName = "st"
    Case 2, 22
        sheetName = "nd"
    Case 3, 23
        sheetName = "rd"
    Case Else
        sheetName = "th"
End Select

sheetName = CStr(Day(Date)) & sheetName

Sheets(sheetName).Activate

End Sub

WBD
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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