单击Excel中的超链接以在其他工作表上设置自动筛选

时间:2016-02-05 19:16:26

标签: excel vba excel-vba

我有一张带有两张纸的Excel工作簿,基本上是两张纸之间的一对多设置。第一张表列出了数百家公司,第二张表列出了公司的董事会。第二张工作表有一个自动过滤器,因此用户可以看到从过滤器中选择的特定公司的董事会成员。

我尝试做的是让用户在第一张纸上单击公司的单元格,然后用户被带到下一张纸张,其中自动过滤器已经填充了所选公司。这样,用户只能直接访问所选公司的董事会成员。

我想这会需要VBA,希望有人能指出我正确的方向来创建这个代码来解决这个问题。非常感谢。

2 个答案:

答案 0 :(得分:3)

您可以通过在工作表模块中执行此操作来完成此操作:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    'Update Table14 to your table name
    'Update Field to column number of the field you are filtering
    'Update Sheet7 to reference the sheet containing your table
    'Change on to the column number where your click should cause this action
    If ActiveCell.Column = 1 Then
    Sheet7.ListObjects("Table14").Range.AutoFilter Field:=1, Criteria1:=ActiveCell.Value
    'Update Sheet7 to reference the sheet containing your table
    Sheet7.Activate
    End If
End Sub

答案 1 :(得分:0)

您需要打开visual basic编辑器,右键单击公司工作表, 查看代码,将其粘贴到:

n = 10
fibo_nums = [0, 1]
while len(fibo_nums) <= n:
    fibo_nums.append(fibo_nums[-2] + fibo_nums[-1])

希望有所帮助,你可以做点什么