根据输入使组形状显示/消失

时间:2017-05-16 10:25:50

标签: vba excel-vba excel

如果“C18”中的输入为1,则组1/2/3/4(线组)应消失。不会发生。

代码:

    Private Sub Design_Click()

    Dim TorsionGroup As ShapeRange
    Dim Toption As Integer

    Set Toption = Range("C18")

    Set TorsionGroup = Shapes.Range(Array("Group 1", "Group 2", "Group 3", "Group 4"))

    If Toption = 1 Then
        ActiveSheet.TorsionGroup.GroupItems().Visible = False
    Else
        ActiveSheet.TorsionGroup.GroupItems().Visible = True
    End If

End Sub

1 个答案:

答案 0 :(得分:0)

Public Sub Design_Click()
    Shapes.Range(["Group "&column(a:d)]).Visible = [C18] = 1
End Sub

或者如果您将组分组到一个组中,只需:

Public Sub Design_Click()
    [Group 5].Visible = [C18] = 1
End Sub