Option Explicit
Private Sub UserForm_Initialize()
Dim i As Byte
For i = 1 To 6 'Nombre d'OptionButtons
Select Case i
Case 1, 2
Me.Controls('OptionButton' & i).GroupName = 'Group1'
Case 3, 4
Me.Controls('OptionButton' & i).GroupName = 'Group2'
Case 5, 6
Me.Controls('OptionButton' & i).GroupName = 'Group3'
End Select
Next i
'Pour activer par défaut les OptionButtons
For i = 1 To 6 Step 2
Me.Controls('OptionButton' & i).Value = True
Next i
End Sub
Private Sub CommandButton1_Click()
Dim i As Byte
Dim L As Byte
L = Sheets('Feuil1').Range('B26').End(xlUp).Row + 1
For i = 1 To 6 'Nombre d'OptionButtons
Select Case i
Case 1
If Me.Controls('OptionButton' & i) = True Then
Range('B' & L) = 'F'
Else
Range('B' & L) = 'M'
End If
Case 3
If Me.Controls('OptionButton' & i) = True Then
Range('C' & L) = 'EMPLOYE'
Else
Range('C' & L) = 'ADMINISTRATIF'
End If
Case 5
If Me.Controls('OptionButton' & i) = True Then
Range('D' & L) = '1er DEGRE'
Else
Range('D' & L) = '2nd DEGRE'
End If
End Select
Next
End Sub