我要做的是在Sheet1上创建一个超链接,自动过滤Sheet2上的表。此表应根据Sheet1中的某个单元格值进行过滤。单元格值根据切片器选择动态变化。
例如,
我对VBA缺乏经验,所以我希望得到一些帮助。
这是我到目前为止所得到的,但是当我尝试点击超链接时没有任何反应。
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If ActiveSheet.Range("S18").Select = 1 Then
'This is the cell with the hyerlink in it.
Worksheets("Table of Presidents").ListObjects("Table17").Range.AutoFilter Field:=13, Criteria1:=Worksheets("Dashboard").Range("S21").Value
'This is the table that needs to be filtered.
'The criteria1 part is the field that dynamically changes
Worksheets("Table of Presidents").Activate
End If
End Sub
答案 0 :(得分:1)
<强>更新强>
回复2-3:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.Type = msoHyperlinkRange And Target.Range.Address = "$S$18" Then
Worksheets("Table of Presidents").ListObjects("Table17").Range.AutoFilter Field:=13, Criteria1:=Worksheets("Dashboard").Range("S21").Value
Worksheets("Table of Presidents").Activate
End If
End Sub