excel hyperlink to nothing

前端 未结 4 1283
旧巷少年郎
旧巷少年郎 2020-11-27 23:25

I\'ve got a lot of hyperlinks and I want to assign a macros to each of them and Worksheet_FollowHyperlink captures only Inserted Hyperlinks but not the HYPERLINK() function.

相关标签:
4条回答
  • 2020-11-27 23:53

    I've just founded a solution. If I refer my Inserted Hyperlink to some cell in other sheet and then make it very hidden (xlSheetVeryHidden), it works just perfect. Now my hyperlinks refer to the Neverland and the macro captures them as well. Thank you all for your patiense.

    0 讨论(0)
  • 2020-11-27 23:56

    You will be better off using the HYPERLINK() function. You can use it for what you want like this:

    =HYPERLINK("#HyperlinkClick()", "Text you want to Display")
    

    Notice the # at the beginning. This is important.

    Now create a function called HyperlinkClick:

    Function HyperlinkClick()
    
        Set HyperlinkClick = Selection
        'Do whatever you like here...
        MsgBox "You clicked on cell " & Selection.Address(0, 0)
    
    End Function
    

    That's it.

    0 讨论(0)
  • 2020-11-27 23:57

    Select a group of cells and run:

    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
    
    0 讨论(0)
  • 2020-11-28 00:05

    Good solution Excel Hero but not for everything: I try to make a kind of outline but it's impossible to hide a row in the function: nothing happen! But if a make a direct call to the same code with a button, everything works fine. This is my test:

    Function test()
    
    Set test = Selection
    
     Dim i, j, state As Integer
    state = Selection.Value
    i = Selection.Row + 1
    j = i
    
    If state = "6" Then
    
        Do Until ActiveSheet.Cells(j, 7).Value = 1 Or ActiveSheet.Cells(j, 4).Value = ""
            j = j + 1
        Loop
        ActiveSheet.Rows(i & ":" & j - 1).EntireRow.Hidden = True
        Debug.Print "test group: " & i & ":" & j - 1
    Else
        Do Until ActiveSheet.Cells(j, 7).Value = 1 Or ActiveSheet.Cells(j, 4).Value = ""
            j = j + 1
        Loop
        ActiveSheet.Rows(i & ":" & j - 1).EntireRow.Hidden = False
        Debug.Print "test ungroup: " & i & ":" & j - 1
    End If
    

    End Function

    My debug.print give me this:

    test group: 4:26

    0 讨论(0)
提交回复
热议问题