Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to disable a checkbox when another checkbox is clicked in excel

Tags:

excel

vba

I want to click a check box and have another linked check box be disabled in Excel.

When I uncheck that particular check box, then the disabled check box should become enabled.

I tried so many things but not able to find the solution. Can I do this without a script?

I have 76 check boxes to work upon. So is this possible without a script? TIA

like image 546
Sangeeta Mishra Avatar asked Sep 29 '22 04:09

Sangeeta Mishra


2 Answers

With two ActiveX check boxes the code would be:

Private Sub CheckBox1_Click()

If CheckBox2.Enabled = True Then
    CheckBox2.Enabled = False
Else:
    CheckBox2.Enabled = True
End If

End Sub

It's simple, but works.

like image 91
tgikal Avatar answered Oct 07 '22 20:10

tgikal


If you want the code to check and disable clicking on the second box, use the below code. If you uncheck the initial box, it will also enable and uncheck the second one.

Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
    CheckBox2.Value = True
    CheckBox2.Enabled = False
Else
    CheckBox2.Value = False
    CheckBox2.Enabled = True
End If
End Sub
like image 39
Brady Avatar answered Oct 07 '22 20:10

Brady