run sub from hyperlink

  • Thread starter Thread starter mgray2004
  • Start date Start date
Include the following event macro in the worksheet code area:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
MsgBox ("Hello world")
End Sub
 
Include the following event macro in the worksheet code area:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
MsgBox ("Hello world")
End Sub
--
Gary''s Student - gsnu2007k





- Show quoted text -

That is helpful but how can I have more than one per sheet each
triggering an different sub routine?
 
Include the following event macro in the worksheet code area:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
MsgBox ("Hello world")
End Sub
--
Gary''s Student - gsnu2007k





- Show quoted text -

that is helpful but how can I have more than one per page each
triggering an different sub? Or how can I tell which which hyperlink
triggered it so I can do a select case or something.
 
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
MsgBox (Target.Parent.Address & Chr(10) & ActiveCell.Address)
End Sub

Try this. You will see that you have:
1. the cell that was clicked on
2. the destination address
 
In fact, you can put the name of the desired macro in the ScreenTip and run
it as follows:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim s As String
s = Target.ScreenTip
Application.Run s
End Sub
 
Back
Top