Search notes:

Excel Object Model: hyperlink event followHyperlink

FollowHyperlink is the event that is triggered when a user clicks on a hyperlink. Because the event is delivered to a worksheet, the name of the sub must be declared as worksheet_followHyperlink and created in the worksheet's code module.
This event is not triggered when a user clicks on a cell with a =hyperlink(…) formula.
option explicit

sub main() ' {

  '
  ' Create a new worksheet on which the
  ' hyperlinks will be created:
  '
    dim sht as worksheet
    set sht = worksheets.add

    with sht

     '
     '  Add three hyperlinks to the sheet
     '
       .hyperlinks.add anchor := .cells(1, 1), textToDisplay := "first link" , screenTip := "foo", address := ""
       .hyperlinks.add anchor := .cells(2, 1), textToDisplay := "second link", screenTip := "bar", address := ""
       .hyperlinks.add anchor := .cells(3, 1), textToDisplay := "third link" , screenTip := "baz", address := ""

       .usedRange.columns.autoFit

      '
      ' Get the worksheet's code module using the worksheet's codeName property:
      '
        dim cdm as vbide.codeModule
        set cdm = application.vbe.activeVBProject.vbComponents(.codeName).codeModule

    end with

  '
  ' Insert the code with the event handler into the code module:
  '
    cdm.insertLines 1, "option explicit"

    cdm.insertLines 2, "private sub worksheet_followHyperlink(byVal hLnk as hyperlink)"
    cdm.insertLines 3, "   msgBox ""Hyperlink was clicked, screenTip is: "" & hLnk.screenTip"
    cdm.insertLines 4, "end sub"

end sub ' }
Github repository about-MS-Office-object-model, path: /Excel/Hyperlink/followHyperlink.bas

See also

The menu Insert -> Links
Catching Excel Events with VBA and worksheet events
The codeModule object.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1758192218, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/Office/Excel/Object-Model/Hyperlink/followHyperlink(92): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78