run sub from hyperlink

  • Thread starter Thread starter mgray2004
  • Start date Start date
M

mgray2004

Is there a way to run a sub routine from a hyperlink in an excell cell?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top