Creating Checkboxes that when click uncheck the other
I'm trying to create some checkboxes in a certain range. The range I have defined has sets of checkboxes next to each other; for example I5 & J5 is a basic yes or no. Same with I7 & J7 etc.
I'd like to make the checkboxes in each set uncheck each other. If yes is checked it will make sure no is unchecked, etc.
I'm having some trouble trying to assign the function with the .OnAction or .OnClick etc. Not sure what I am doing wrong here.
Code:
Public Sub Add_Checkboxes()
'Delete all preexisting checkboxes
For Each c In Worksheets(1).CheckBoxes
c.Delete
Next
'Generate the checkboxes in a predefined range
Dim rngChkBoxes As Range: Set rngChkBoxes = Range("I5, J5, I7, J7, I9, J9, I18, J18")
For Each Rng In rngChkBoxes
Worksheets(1).CheckBoxes.Add(Left:=Rng.Left, Top:=Rng.Top, Width:=Rng.Width, Height:=Rng.Height).Select
With Selection
.Caption = ""
'.Name = "chk_"
'.OnClick = IsChecked()
End With
Next Rng
End Sub
Public Sub IsChecked()
MsgBox ("testing")
End Sub