Let me start off by stating that I am a medical student, not a programmer. I have written a spreadsheet that will work as an exam with 50 questions. Each question has 15 multi
The way to create a group event is to have a custom class to wrap the controls that you want to group and a module level collection to keep the wrapper class references alive.
After reviewing your workbook I determined that you can derive an index based on the OptionButton's Name.
Option Explicit
Public WithEvents MyOptionButton As MSForms.OptionButton
Private Sub MyOptionButton_Click()
Dim Letters()
Dim lRow As Long, lAnswer As Long, ID As Long
Letters = Array("O", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N")
ID = Replace(MyOptionButton.Name, "OptionButton", "")
lRow = Int(ID / 15 + 1) * 21
lAnswer = ID Mod 15
Cells(lRow, "B") = Letters(lAnswer)
End Sub
Private OptionsCollection As Collection
Private Sub Worksheet_Activate()
Dim obj As OLEObject
Dim wrap As OptionWrapper
Set OptionsCollection = New Collection
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.OptionButton Then
Set wrap = New OptionWrapper
Set wrap.MyOptionButton = obj.Object
OptionsCollection.Add wrap
End If
Next
End Sub