SheetFollowHyperlink Event

Microsoft Office Web Components Visual Basic

Private Sub object_SheetFollowHyperlink(ByVal Sh As Worksheet, Target As Hyperlink)

object Required. The name of a Spreadsheet object that you are trapping this event for.

Sh    Required. The worksheet that has been deactivated.

Target Required. The hyperlink that has been clicked.

Example

This example keeps a log of hyperlinks clicked in Spreadsheet1. The name of the sheet containing the hyperlink and the target address are written to Sheet3 each time that a hyperlink is clicked.

Sub Spreadsheet1_SheetFollowHyperlink(Sh, Target)

    Dim ssConstants
    Dim rngNewItem
    Dim shtListSheet

    Set ssConstants = Spreadsheet1.Constants

    ' Set a variable to Sheet3.
    Set shtListSheet = Spreadsheet1.ActiveWorkbook.Worksheets("Sheet3")

    ' Set a variable to the first available cell in column A of Sheet3.
    Set rngNewItem = shtListSheet.Range("A262144").End(ssConstants.xlUp).Offset(1, 0)

    ' Write the name of the sheet to Column A of Sheet3.
    rngNewItem.Value = Sh.Name

    ' Write the target address of the hyperlink to Column B of Sheet3.
    rngNewItem.Offset(0, 1).Value = Target.Address

End Sub