Consulting

Results 1 to 3 of 3

Thread: Solved: Trigger a Macro with a hyperlink

  1. #1
    VBAX Newbie
    Joined
    Oct 2007
    Posts
    2
    Location

    Solved: Trigger a Macro with a hyperlink

    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.

  2. #2
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    You can use the Worksheet's FollowHyperlink event:

    [vba]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
    [/vba]

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

    Microsoft MVP - Excel

  3. #3
    VBAX Newbie
    Joined
    Oct 2007
    Posts
    2
    Location
    Thanks a lot it work just great!!
    It seems easy enough if one knows the following stuff which I did not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •