简体   繁体   English

使用VBA Excel检查打开工作表复选框

[英]open a sheet checkbox is checked with vba excel

how I can check if a checkbox is selected ? 我如何检查是否选中了复选框? And after selecting a checkbox for example "a" (in my example) I want to open a excel sheet. 在选择了一个复选框后,例如“ a” (在我的示例中),我想打开一个Excel工作表。

在此处输入图片说明

How can I solve this problem? 我怎么解决这个问题? Thank you all. 谢谢你们。

In the UserForm module you can just place the following code, when your CheckBox is named "CheckBox1": 当您的CheckBox命名为“ CheckBox1”时,您可以在UserForm模块中放置以下代码:

Private Sub CheckBox1_Click()
    If Me.CheckBox1.Value = True Then
        Worksheets("Sheet1").Visible = True
    Else
        Worksheets("Sheet1").Visible = False
    End If
End Sub

This will make "Sheet1" visible when it's checked and invisible when unchecked. 这将使“ Sheet1”在选中时可见,而在未选中时不可见。 If you name your checkbox differently, you'll see that if you double click the checkbox in the Userform Design, the VBE will already come up with 如果您用不同的方式命名复选框,则会看到,如果双击用户窗体设计中的复选框,则VBE将已经出现

Private Sub CheckBoxName_Click()

End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM