VBA masters,
I have an Excel Userform that has a frame called studentFrame. In that frame, I am programmatically creating buttons with the following code:
nCheckTopPosition = 30
nLabelTopPositionName = 30
nLabelTopPositionGoal = 30
nNoOfCheckBoxes = mySht.Cells(mySht.Rows.Count, "A").End(xlUp).Row
For nControlIndex = 1 To nNoOfCheckBoxes
Dim chkBox As Control
Set chkBox = screen3Form.studentFrame.Controls.Add("Forms.CommandButton.1", "chkCheck" & nControlIndex, True)
chkBox.Left = 12
chkBox.Width = 30
chkBox.Height = 18
chkBox.Caption = "GAO"
chkBox.Top = nCheckTopPosition
nCheckTopPosition = nCheckTopPosition + 30
Next
When I run the userform, I now need to capture which of these buttons is pressed and execute more code. How can I accomplish this? There can be anywhere from 1 to 100 buttons being created.