Execute Macros through Hyperlinks.

  • Thread starter Thread starter saddat
  • Start date Start date
S

saddat

could anybody help my in this regard? I need to execute Macros by using
simple text links (hyperlinks). I can run macros through images or form
objects, but now the problem is bit different. I dont even have an idea
how to run macros through hyperlinks. please guys help me out in this
regard, it is very urgent for me. thanks and regards,

Saddat Sarfraz
(Saadi)
 
Create hyperlinks which just point to the same cell the hyperlink is in.
Handle the sheet's FollowHyperlink event to dtermine which link was clicked.

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

Select Case Target.Address 'or some other property
Case "D8": MsgBox "call a macro"
Case "D9": MsgBox "call a different macro"
End Select

End Sub

....replace the Msgbox with calls to the appropriate macro.

Tim
 
thanks Tim for your reply,

could you also help me out and tell me how do I call the Macro. may I
just need to wrtie the name of the macro in place of MsgBox function.

thanks,

Saddat Sarfraz
(Saadi)
 
may I just need to wrtie the name of the macro in place of MsgBox function.
Yes - that's all you need to do
....
Case "whatever": MacroName
....

Tim
 
Sorry to trouble you again.

I am trying to run the command but nothing is happaning. I tried with
Macro as well as MsgBox Function, nothing is working.
 
Show the exact code which is not working.
What does it do instead of working?

tim
 
Hi,
This worked:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)

Select Case ActiveCell.Address

Case "$D$8": MyMacro
Case "$D$9": MsgBox "call a different macro"

End Select

End Sub

Sub MyMacro()
MsgBox "MyMacro called"
End Sub


HTH
 

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