I have hyperlinks in a worksheet that jump to cells using a named range in other worksheets. The below working code switches worksheets (based on hyperlink) and puts the target cell in the upper left hand corner when I click on the hyperlink. This works perfectly.
However, on one particular hyperlink I want it to only switch to the worksheet but I don't want to run the below code to have it placed in the Upper left. I just want to switch worksheets and leave positioning alone.
Since the below code is an event when any hyperlink is clicked I would like to check for the particular target worksheet and not run the below code.
Is there a way (if...then?) to detect the worksheet I'm switching to and not execute the below code?
Thanks in advance.
Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
ActiveWindow.ScrollRow = ActiveCell.Row
ActiveWindow.ScrollColumn = ActiveCell.Column
End Sub
Psuedo Code - I'm looking for the VBA code in bold.
Option Explicit
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
**If (name in hyperlink) = "my target sheet" Then exit sub**
ActiveWindow.ScrollRow = ActiveCell.Row
ActiveWindow.ScrollColumn = ActiveCell.Column
End Sub