flowers1234
flowers1234

Reputation: 345

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.

enter image description here

How can I solve this problem? Thank you all.

Upvotes: 0

Views: 1322

Answers (1)

Rik Sportel
Rik Sportel

Reputation: 2679

In the UserForm module you can just place the following code, when your CheckBox is named "CheckBox1":

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. 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

Private Sub CheckBoxName_Click()

End Sub

Upvotes: 1

Related Questions