Macro to Hyperlink a cell to itself

前端 未结 1 1642
情话喂你
情话喂你 2021-01-23 16:11

I have already created a macro that allows me to double click a hyperlink and it displays information from another sheet based on the cell that I have clicked on.

Now I

相关标签:
1条回答
  • 2021-01-23 16:42

    Select some cells and run this:

    Sub HyperAdder()
       For Each r In Selection
          ActiveSheet.Hyperlinks.Add Anchor:=r, Address:="", SubAddress:=r.Parent.Name & "!" & r.Address(0, 0), TextToDisplay:="myself"
       Next r
    End Sub
    

    to insert hyperlinks in the cells to jump to themselves.

    To preserve the cell's contents, use:

    Sub HyperAdder()
        Dim r As Range, s As String
        For Each r In Selection
            If Len(r.Text) = 0 Then
                s = "X"
            Else
                s = r.Text
            End If
            ActiveSheet.Hyperlinks.Add Anchor:=r, Address:="", SubAddress:=r.Parent.Name & "!" & r.Address(0, 0), TextToDisplay:=s
        Next r
    End Sub
    
    0 讨论(0)
提交回复
热议问题