Radio Buttons in cells without control toolbox

tracktor

Board Regular
Joined
Sep 13, 2009
Messages
62
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
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top