Private Sub CommandButton1_Click()
Const TextNum = "2,6,7,10,11,18,19"
Const ComboNum = "1,3,6"
Dim c As Control, nok As Boolean
For Each c In UserForm1.Controls
If c.Name Like "TextBox*" Then
If InStr("," & TextNum & ",", "," & Replace(c.Name, "TextBox", "") & ",") > 0 Then
If Len(c.Value) = 0 Then
c.Enabled = True
c.BackColor = RGB(255, 0, 0)
nok = True
Else
c.BackColor = RGB(255, 255, 255)
End If
End If
ElseIf c.Name Like "ComboBox*" Then
If InStr("," & ComboNum & ",", "," & Replace(c.Name, "ComboBox", "") & ",") > 0 Then
If Len(c.Value) = 0 Then
c.Enabled = True
c.BackColor = RGB(255, 0, 0)
nok = True
Else
c.BackColor = RGB(255, 255, 255)
End If
End If
End If
Next c
If nok Then
MsgBox "Merci de completer les zones manquantes!"
Else
MsgBox "Votre saisie est maintenant complète"
End If
End Sub