Hyperlink to today's date

G

Grim/Don

I tried adjusting your code like so:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim val As Long, r As Long

If Target.Address <> "$A$1" Then
val = Date
r = Application.Match(Date, Range("A2:A65536"), 1) + 1
Application.Goto Cells(Application.Max(2, r - 9), 1), Scroll:=True
Application.Goto Cells(r - 3, 1)
End If

End Sub

but it won't fire on a double click on cell A1. I also added "end if
after the Then, but still no go.

I tried to put today's date in a cell, then using that as the referenc
for a hyperlink, but the hyperlink function is limited..
 
D

Dave Peterson

It won't fire when you double click on A1. But it will fire when you change the
selection to A1.

And sometimes VBA doesn't work nicely with dates. This slightly modified
version of David McRitchie's code still uses the _selectionchange event:

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim r As Long

If Target.Address <> "$A$1" Then Exit Sub

With Application
r = .Match(CLng(Date), Range("A2:A65536"), 1) + 1
.EnableEvents = False
.Goto Cells(Application.Max(2, r - 9), 1), Scroll:=True
.Goto Cells(r - 3, 1)
.EnableEvents = True
End With

End Sub
 
Top