我创建了一个鼠标悬停宏,当鼠标悬停在某些单元格上时,会将链接单元格中的值[Expanded_Rollover]更改为"查看展开的详细信息"或"查看数据过滤器"。从这个链接的单元格,基于上述任一值,我想创建隐藏或显示列的代码" O:S"我的仪表板。我有一个代码可以单独隐藏和显示列,但我无法将这两个代码链接到鼠标悬停时立即工作。请帮助!!
Public Function ExpandedRollover(Expanded_Options As String)
'Cell Expanded Rollover = Moused over cell value in Expanded_Options Range - Values are 1 or 2
[Expanded_Rollover] = Expanded_Options
'Call Private Sub located on Dashboard Sheet
Call ExpandedDetailsShowHide
End Function
Private Sub ExpandedDetailsShowHide()
Dim Expanded_Rollover As Integer
If [Expanded_Rollover] = 1 Then
ActiveSheet.Columns("O:S").Select
If Selection.EntireColumn.Hidden Then
ActiveSheet.Columns("O:S").Select
Selection.EntireColumn.Hidden = True
ActiveSheet.Range("E4").Select
Else:
If [Expanded_Rollover] = 2 Then
ActiveSheet.Columns("O:S").Select
If Selection.EntireColumn.Hidden Then
ActiveSheet.Columns("O:S").Select
Selection.EntireColumn.Hidden = False
ActiveSheet.Range("E4").Select
End If
End If
End Sub
答案 0 :(得分:0)
你一个接一个地调用这些代码。
[Expanded_Rollover] = "something"
Call HideUnhideColumns
End Function
Private Sub HideUnhideColumns
' reads the linked cell value
' hides/unhides columns
End Sub