Is there macro that can scroll to a date in a column?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,


I have a sheet with this years calendar in it (so you can imagine it 365 columns wide

I row1 I have the dates Start In Column G with 01/01/2017 and go up one day at a time across the page to give me my calendar

in A2 in Have todays date

hat Id like is a macro that when I select the sheet (on activate!) it automaticly takes me to row 1 and the todays date?

Any ides how this can be done?

Please help thanks

Tony
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
goes in sheet code module.
Code:
Private Sub Worksheet_Activate()
 Range("1:1").Find(Date, , xlValues).Select
End Sub

You might prefer this

Code:
Private Sub Worksheet_Activate()
 Range("1:1").Find(Date, , xlValues).Select
 ActiveWindow.ScrollColumn = Selection.Column
End Sub
 
Last edited:
Upvote 0
In your second Macro, If I substitute the following below -- I get an code-error RT 91 -- Why?

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim Rng As Range
Cancel = True
Set Rng = Range("G1:NG1")
With Rng
    .Find(Range("G$2").Value, , xlValues).Select
    ActiveWindow.ScrollColumn = Selection.Column
End With
End Sub
 
Upvote 0
In your second Macro, If I substitute the following below -- I get an code-error RT 91 -- Why?

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim Rng As Range
Cancel = True
Set Rng = Range("G1:NG1")
With Rng
    .Find(Range("G$2").Value, , xlValues).Select
    ActiveWindow.ScrollColumn = Selection.Column
End With
End Sub

don't know, Jim. I cannot duplicate the error. It works as expecdted for me. Is there something in your worksheet (or not in your sheet) that would prevent the variable from setting? Does the target value exist?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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