Cell value change based on multiple checkbox

Dears,

how can I change one cell value based on which checkbox is checked? for example, value cell is A1, and I have 5 checkboxes with different names, lets say CB1, CB2, CB3...etc. if i checked CB1 then A1 value will be 1, if checked CB2 then A1 value will be 2, if checked CB3 then A1 value will become 3 and so on.

I used this macro for ActiveX checkbox:
Private Sub CB1_Click()
If CB1.Value = True Then
[a1] = 1

Else

[a1] = 0

End If
End Sub

it works, but I want to be able to check only one box at a time, so if CB1 is already check and I then check CB2 then CB1 will be unchecked automatically an A1 value will change to 2 since CB2 is checked.

I hope my above explanation is clear.

thanks in advance.

Option buttons

Hi,

Try to use option buttons instead of check boxes.
First of all, it will give you the possibility to mark only one option at once without adding an extra VB code. Just do remember to collect option buttons in one group (by using Properties window for these option buttons).
Then, just add the code for each option button similar to this:

Private Sub OptionButton1_Click()

If OptionButton1.Value = True Then ThisWorkbook.Worksheets(1).Range("A1").Value = 1

End Sub

For each option button use a different value.

I hope this is what you are looking for :o)