1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| Option Explicit
Private Sub CommandButton1_Click()
Dim dern_ligne As Long
Dim ligne_identifiant As Byte
dern_ligne = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row 'on cherche la dernière ligne du tableau
For ligne_identifiant = 2 To dern_ligne 'on boucle sur les identifiants
If TextBox1 = Sheets(1).Cells(ligne_identifiant, 1) Then 'test logique de la valeur du textbox
'On compare
If Sheets(1).Cells(ligne_identifiant, 2) = "Oui" Then
UserForm1.Show
Exit For
ElseIf Sheets(1).Cells(ligne_identifiant, 3) = "Oui" Then
UserForm2.Show
Exit For
ElseIf Sheets(1).Cells(ligne_identifiant, 4) = "Oui" Then
UserForm3.Show
Exit For
End If
ElseIf ligne_identifiant = dern_ligne Then 'Si aucun identifiant ne correspond
MsgBox "Identifiant Incorrect", vbInformation
Exit Sub
End If
Next ligne_identifiant
Unload Me 'On ferme le Userform
End Sub |
Partager