Linking Radio Buttons for Test

Joined
May 10, 2012
Messages
6
Reaction score
0
I have been reading a lot of comments on how to use radio buttons and have been seeing a lot fo different versions. What I am looking for is a scoring system. So in my worksheet which I cannot seem to attach, I have inserted the Group Box and four option buttons, each located in cells k19,20,21 and 22 I want the option buttons to link to cell K18, with the answer of A,B,C, or D. I have only provided one set as once I get the code for it I am sure I can copy the rest.
 
Joined
Sep 3, 2008
Messages
164
Reaction score
5
Create the radio buttons then shift click to select them, right click and group them.
Right click on the first one, select format control, select the cell you want to link.
When I just tested it with a group of four buttons the linked cell values were 1, 2, 3, and 4.

Steve
 
Joined
May 10, 2012
Messages
6
Reaction score
0
Thanks. That worked, but I need to change the numbers to letters, which I managed but not the way it should be. See code below. If I had a separate subroutine for each radio button then it would work, but when they are combined under the same subroutine, it only comes up with one of the letters, and it comes up with an error stating that it "can't execute in break mode." Perhaps you know how to shorten this and make it a simpler code?

Sub QUESTION_1()
'
' QUESTION_1 Macro
'
'
ActiveSheet.Shapes("1A").Select
If Range("K18").Select Then
ActiveCell.FormulaR1C1 = "A"

Else

ActiveSheet.Shapes("1B").Select
If Range("K18").Select Then
ActiveCell.FormulaR1C1 = "B"

Else

ActiveSheet.Shapes("1C").Select
If Range("K18").Select Then
ActiveCell.FormulaR1C1 = "C"

Else

ActiveSheet.Shapes("1D").Select
If Range("K18").Select Then
ActiveCell.FormulaR1C1 = "D"
End If
End If
End If
End Sub
 
Joined
May 10, 2012
Messages
6
Reaction score
0
I have it figured out, but only if each of the buttons have their own subroutine but are linked to the same cell. So if there is another way that someone knows to combine those into one subroutine, that would be appeciated.

Sub Button_1A()
ActiveSheet.Shapes("1A").Select
Range("K18").Select
ActiveCell.FormulaR1C1 = "A"

End Sub

Sub Button_1B()
ActiveSheet.Shapes("1B").Select
Range("K18").Select
ActiveCell.FormulaR1C1 = "B"

End Sub
Sub Button_1C()
ActiveSheet.Shapes("1C").Select
Range("K18").Select
ActiveCell.FormulaR1C1 = "C"

End Sub
Sub Button_1D()
ActiveSheet.Shapes("1D").Select
Range("K18").Select
ActiveCell.FormulaR1C1 = "D"

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top