如何引用名为delete的特定超链接,而不是以下代码中具有不同名称的其他超链接:
{{1}}
上面的代码是超链接的处理程序,但我希望只有在父工作簿中单击“删除”超链接时才能使用此代码。 感谢所有试图帮助的人!
答案 0 :(得分:0)
我猜测哪个工作表的事件启动了Workbook_SheetFollowHyperlink event宏并不重要。
Private Sub Workbook_SheetFollowHyperlink(ByVal sh As Object, ByVal Target As Hyperlink)
If LCase(Target.Name) = "delete" Then
ClearThatCell sh, Target.Range 'Calling ClearThatCell sub
End If
End Sub
Sub ClearThatCell(ws As Worksheet, rng As Range)
MsgBox "The " & rng.Address(0, 0) & " cell on " & ws.Name & " was clicked."
End Sub
检查Hyperlink object和Hyperlink members的文档,看看您还可以使用超链接做些什么。
答案 1 :(得分:0)
Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, ByVal Target As Hyperlink)
If Target.TextToDisplay = "Delete" Then
Debug.Print "deleting"
'do stuff
End If
End Sub