Worksheet_FollowHyperlink()在Module2和Module3中,我试图从Sheet00中调用它。
Sheet00
Sub data_hyplink()
Dim ws As Worksheet
i = 1
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "main" Then
Sheets("main").Cells(i, 2).Hyperlinks.Add Anchor:=Sheet00.Cells(i, 2), Address:="", SubAddress:="", TextToDisplay:=""
Sheets("main").Cells(i, 3).Hyperlinks.Add Anchor:=Sheet00.Cells(i, 3), Address:="", SubAddress:="", TextToDisplay:=""
i = i + 1
End If
Next
End Sub
Sub display_sheets(ByVal Target As Range)
Call Module2.Worksheet_FollowHyperlink
Call Module3.Worksheet_FollowHyperlink
End Sub
Module2和Module3中的示例内容(它们唯一的区别是地址)
Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Range.Address = "$B$2" Then
a_asb_mw.Visible = xlSheetVisible
a_asb_mw.Activate
ElseIf Target.Range.Address = "$B$3" Then
a_asb_wn.Visible = xlSheetVisible
a_asb_wn.Activate
...
EndIf
每当点击超链接的单元格时,它应该打开隐藏的工作表,但是,我似乎无法使它工作。也许这是我试图通过Sub zz_display(ByVal Target As Range)
的参数,这是不正确的。我试过了ByVal Target As Hyperlink
,但它也没有用。
我错过了什么?非常感谢你的帮助。
答案 0 :(得分:0)
只需将此宏放在Sheet00中,它就可以完成您想要的任务。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$2" Then
Sheets("a_asb_wm").Visible = True
Sheets("a_asb_wm").Activate
End If
If Target.Address = "$B$3" Then
Sheets("a_asb_wn").Visible = True
Sheets("a_asb_wn").Activate
End If
End Sub