mercredi 14 mars 2018

Deselecting a checkbox when another is checked

I have two checkboxes, form controls, if I select one, the other one is deselected. I cannot use ActiveX controls because there are many other checkboxes from other sheets are form controls. I cannot use option button because I need to get "true" "false" value.

I used this code below:

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
    CheckBox2.Value = False
    CheckBox2.Enabled = False
Else
    CheckBox2.Enabled = True
End If
End Sub

Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
    CheckBox1.Value = False
    CheckBox1.Enabled = False
Else
    CheckBox1.Enabled = True
End If
End Sub

But it shows

Run-time error '424', Object required

I am very new to VBA and still learning. I have no idea to fix it, please help me!! Thank you very much!!




Aucun commentaire:

Enregistrer un commentaire