If ComboBox1.ListIndex = -1 And ComboBox2.ListIndex = -1 And ComboBox3.ListIndex = -1 And ComboBox4.ListIndex = -1 And ComboBox5.ListIndex = -1 And ComboBox6.ListIndex = -1 And ComboBox7.ListIndex = -1 And ComboBox8.ListIndex = -1 Then
MsgBox "Nom obligatoire", vbExclamation
Exit Sub
End If
En encore plus long mais il en fait un tout petit peu plus
VB:
Private Sub CommandButton1_Click()
Dim i&
For i = 1 To 8
If Controls("Combobox" & i).ListIndex = -1 Then
MsgBox "Pas d'élément sélectionné pour la liste n° " & i & " !", vbExclamation
Controls("Combobox" & i).SetFocus
Application.SendKeys ("%{DOWN}")
Exit Sub
End If
Next i
End Sub
Mille excuses. J'avais encore une fois mal lu et rattaché à un cas déjà rencontré
Bon, on adapte le cas précédent:
VB:
Private Sub CommandButton1_Click()
Dim i&, s&
For i = 1 To 8: s = s + Controls("Combobox" & i).ListIndex: Next
If s = -8 Then
MsgBox "Aucune sélection dans aucune liste!", vbExclamation
Exit Sub
End If
End Sub