VBA code to open a sheet at the current date in a row

snmark

New Member
Joined
May 14, 2007
Messages
25
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi guys, can anyone help me with this please. I have a sheet with dates in column B going all the way down to December 31st ( 31/12/2023). I'd like a code to have the sheet open at the current date if that's possible. Thank you

stephen
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
In the VBA window, double click to Workbook on the left pane. Paste this code into workbook:
VBA Code:
Private Sub Workbook_Open()
  Worksheets("Sheet1").Cells(Application.Match(CLng(CDate(Now)), Range("B:B"), 0), "B").Select
End Sub
 
Upvote 0
Solution
In the VBA window, double click to Workbook on the left pane. Paste this code into workbook:
VBA Code:
Private Sub Workbook_Open()
  Worksheets("Sheet1").Cells(Application.Match(CLng(CDate(Now)), Range("B:B"), 0), "B").Select
End Sub

In the VBA window, double click to Workbook on the left pane. Paste this code into workbook:
VBA Code:
Private Sub Workbook_Open()
  Worksheets("Sheet1").Cells(Application.Match(CLng(CDate(Now)), Range("B:B"), 0), "B").Select
End Sub
Thank you Flashbond, works a treat!
 
Upvote 0
In future please mark the post that contains the solution, rather than your post saying it works. Thanks
 
Upvote 0

Forum statistics

Threads
1,214,823
Messages
6,121,780
Members
449,049
Latest member
greyangel23

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