Cell Ref Before follow hyperlink event

Ziggy12

Active Member
Joined
Jun 26, 2002
Messages
365
Hi there
Have got a before follow hyperlink event

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
HyperDrive
End Sub

What I want to do is capture the active cell reference on the active sheet before the hyper link is activated.

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
CurrAddr = activecell.address
HyperDrive
End Sub

CurrAddr returns where the hyper link is linked to not where it was.

I want to be able users to click the hyperlink to a help screen and click another to get back where they were. Hyperlink seems to default to cell A1. Have an idea the option to specify the specific cell is in the insert hyperlink dialog box somewhere.

cheers
Ziggy
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Maybe this will work for you. Set a module level flag to store the address of the last range that was selected via the _SelectionChange event as follows :

Code:
Private oPrevSelection As Range
 
Private Sub Worksheet_FollowHyperlink _
(ByVal Target As Hyperlink)
 
    Dim CurrAddr As String
    CurrAddr = oPrevSelection.Address
    MsgBox CurrAddr
 
End Sub
 
Private Sub Worksheet_SelectionChange _
(ByVal Target As Range)
 
    Dim oHyplnk As Hyperlink
    On Error Resume Next
    Set oHyplnk = Target.Hyperlinks(1)
    If Err <> 0 Then
        On Error GoTo 0
        Set oPrevSelection = Target
    End If
 
End Sub

Regards.
 
Upvote 0
Didn't work. Think CurrAddr goes in as the target or at least in the brackets of the event call somewhere.

Ziggy
 
Upvote 0
Didn't work. Think CurrAddr goes in as the target or at least in the brackets of the event call somewhere.

Ziggy

I must have misunderstood your question. Maybe if you could rephrase what exactly you are trying to do . I guess your first post is not quite clear.

Regards.
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

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