run sub from hyperlink

G

Gary''s Student

Include the following event macro in the worksheet code area:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
MsgBox ("Hello world")
End Sub
 
M

mg

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?
 
M

mg

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.
 
G

Gary''s Student

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
 
G

Gary''s Student

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
 
Top