PDA

View Full Version : Solved: Trigger a Macro with a hyperlink



aommunoz
10-05-2007, 06:36 AM
Hi,
I have an Excel2003 application with two spreadsheets.
Sheet1 contains visualization of data seleted with a drop drown menu associated with a VBA Macro.
I want to add hyperlinks to the sheet2 that
1-show sheet1
2-trigger a macro to update the values in sheet1.
I do not manage to trigger a macro by just clicking on a hyperlink.
I have seen related posts that did not help me up to now but never a generic way as to how to trigger a macro by a hyperlink.
Thanks for your help.

rory
10-05-2007, 06:57 AM
You can use the Worksheet's FollowHyperlink event:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Range.Address = "$A$1" Then
MsgBox "it's the hyperlink in A1"
Call YourMacroHere
End If
End Sub


Just point the hyperlink target at the same cell as you add it to, and alter the address in the code as required.

aommunoz
10-05-2007, 08:31 AM
Thanks a lot it work just great!!
It seems easy enough if one knows the following stuff which I did not.