Go to Today Macro

G

Guest

Guest
Does anyone have a quick "Go to Today" macro

My SS has sates across the top but i need a button that will take me to the correct row for today?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Assuming:
(a) you have a button from the Control Toolbox
(b) you meant dates instead of sates, and
(c) correct column instead of correct row.

From the Control Toolbox (View | Toolbars > Control Toolbox) create a command button. Right click the button and select Properties. Change the Name to GoToToday. Change the Caption to 'Go To Today'. Double-click the button. Replace the
Code:
Option Explicit

Private Sub GoToToday_Click()

End Sub

with
Code:
Option Explicit

Private Sub GoToToday_Click()
    On Error Resume Next
    ActiveSheet.Rows("1:1").Find(What:=Date, After:=Cells(1, 1), LookIn:=xlFormulas _
        , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
    If Err.Number <> 0 Then Beep
    End Sub
Get back to XL. Exit design mode by clicking the button on the 'Exit Design Mode' commandbar.

The code above assumes row 1 contains the dates entered in a form that XL understands as a date.
 
Upvote 0

Forum statistics

Threads
1,203,670
Messages
6,056,666
Members
444,881
Latest member
Stu2407

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