Question posted 2012 · +3 upvotes
I have 2 checkboxes, what i want to do is when i select one, the other 1 will be deselected, which means user will not have the ability to select it the other checkbox. I was wondering if it is possible to do so?
Accepted answer +8 upvotes
Yes it is possible. But why not use an option button instead?
Anyways to answer your query.
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
FOLLOWUP
Thanks for the fast update! what is the difference between a checkbox and option button? I thought they do the same thing? â user1204868 48 secs ago
Excel VBA Option Buttons (Also known as radio buttons) are the same as Check Boxes except that Option Buttons are dependent on each other while Check Boxes are not. When you check one Option Button the other Option Button will automatically get unchecked.
See the snapshot below on how they look 🙂
Would recommend seeing the Excel’s inbuilt VBA help for more details 😉
SNAPSHOT:

HTH
Sid
Top excel-vba Q&A (6)
- How to clear the entire array? +58 (2010)
- How to change Format of a Cell to Text using VBA +55 (2011)
- Download attachment from Outlook and Open in Excel +43 (2012)
- Can a VBA function in Excel return a range? +36 (2009)
- 2 Dimensional array from range +34 (2013)
- Hiding an Excel worksheet with VBA +33 (2009)
excel-vba solutions on this site
.