11楼的代码有个风险,若Frame里有个CheckBox,同时又被选中的话,就不符合楼主的要求了。
Private Sub CommandButton1_Click()
Dim mycontrol As Control
For Each mycontrol In Me.Controls
If TypeName(mycontrol) = "OptionButton" Then
If mycontrol.Value = True Then
MsgBox mycontrol.Caption
End If
End If
Next
End Sub
借用12#,比如把第1个值赋给A1,第2个值给A3。
Private Sub CommandButton1_Click()
Dim mycontrol As Control, i
For Each mycontrol In Me.Controls
If TypeName(mycontrol) = "OptionButton" Then
If mycontrol.Value = True Then
i = i + 1
Cells(i, 1) = mycontrol.Caption
End If
End If
Next
End Sub
不知要放到哪儿,再改吧