Hello
I have a multipage userform which includes around 50 sets of 3 togglebuttons. Each set of 3 togglebuttons are within a frame and the frame includes a textbox and a label. The 3 toggle buttons are option answers to questions and the user must select one of the three togglebuttons for their answer of 'yes', 'no' or 'not applicable'. On selecting the correct button, the answer is placed into a specific cell on the worksheet.
I have the following code, which works fine for one set of the buttons:
'###################################
'########## 5.1 YES NO NA BUTTONS ############
'###################################
Private Sub ToggleButton51Y_Click()
If ToggleButton51Y.Value = True Then
Sheets("Input").Range("k71") = "Yes"
ToggleButton51Y.BackColor = RGB(20, 255, 3)
ToggleButton51N.Value = False
ToggleButton51N.BackColor = &H8000000F
ToggleButton51NA.Value = False
ToggleButton51NA.BackColor = &H8000000F
End If
End Sub
Private Sub ToggleButton51N_Click()
If ToggleButton51N.Value = True Then
Sheets("Input").Range("k71") = "No"
ToggleButton51N.BackColor = RGB(255, 20, 3)
ToggleButton51Y.Value = False
ToggleButton51Y.BackColor = &H8000000F
ToggleButton51NA.Value = False
ToggleButton51NA.BackColor = &H8000000F
End If
End Sub
Private Sub ToggleButton51NA_Click()
If ToggleButton51NA.Value = True Then
Sheets("Input").Range("k71") = "N/A"
ToggleButton51NA.BackColor = RGB(145, 145, 145)
ToggleButton51Y.Value = False
ToggleButton51Y.BackColor = &H8000000F
ToggleButton51N.Value = False
ToggleButton51N.BackColor = &H8000000F
End If
End Sub
Rather than repeat the code 50+ times, could someone point me in the right direction to be able to use the code once in a module (?) and then be able to call that module for each set of the 3 togglebuttons? It may be difficult as each answer is transferred into a non-consecutive cell in the workbook?
Thank you in advance for any pointers.
Bookmarks