dans un userform j'ai deux optionbutton relié au groupnam Valeur le code ci-dessous
'attribut les options boutons Valeur
For Each Ctrl In Controls
If TypeName(Ctrl) = "OptionButton" Then
If Ctrl And Ctrl.GroupName = "Valeur" Then
Valeur = Ctrl.Caption
Exit For
End If
End If
regarde ceci, à placer dans le module de l'userform :
Code:
Option Explicit
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Cancel = OptionButton1 + OptionButton2 = 0
If Cancel Then MsgBox "cocher option..."
End Sub