Instead of using radio buttons from the control toolbox, I have created a radio button type of group within 3 cells the code is as follows:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then [C1,E1].ClearContents
If Target.Address = "$C$1" Then [A1,E1].ClearContents
If Target.Address = "$E$1" Then [A1,C1].ClearContents
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1, C1, E1 ")) Is Nothing Then
Target.Font.Name = "Webdings"
If Target = vbNullString Then
Target = "g"
Else
Target = vbNullString
End If
What this does is puts an “g” in the cell that is clicked on and clears the other two cells. What I want it to do instead is to put a “c” in the cells that are cleared. With the Webdings font this makes the cells with a "g" in them look like a filled checked box and the cells with a "c" in them an unfilled checked box.
I have tried the following code and it works with an exception. The cell that you want to select has to be selected twice (clicked in once, clicked out of once, and clicked in again).
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then [C1,E1] = "c"
If Target.Address = "$C$1" Then [A1,E1] = "c"
If Target.Address = "$E$1" Then [A1,C1] = "c"
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1, C1, E1 ")) Is Nothing Then
Target.Font.Name = "Webdings"
If Target = vbNullString Then
Target = "g"
Else
Target = vbNullString
End If
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then [C1,E1].ClearContents
If Target.Address = "$C$1" Then [A1,E1].ClearContents
If Target.Address = "$E$1" Then [A1,C1].ClearContents
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1, C1, E1 ")) Is Nothing Then
Target.Font.Name = "Webdings"
If Target = vbNullString Then
Target = "g"
Else
Target = vbNullString
End If
What this does is puts an “g” in the cell that is clicked on and clears the other two cells. What I want it to do instead is to put a “c” in the cells that are cleared. With the Webdings font this makes the cells with a "g" in them look like a filled checked box and the cells with a "c" in them an unfilled checked box.
I have tried the following code and it works with an exception. The cell that you want to select has to be selected twice (clicked in once, clicked out of once, and clicked in again).
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then [C1,E1] = "c"
If Target.Address = "$C$1" Then [A1,E1] = "c"
If Target.Address = "$E$1" Then [A1,C1] = "c"
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1, C1, E1 ")) Is Nothing Then
Target.Font.Name = "Webdings"
If Target = vbNullString Then
Target = "g"
Else
Target = vbNullString
End If