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 40 41 42 43 44 45 46 47 48 49 50 51
| Private Sub Button_Rechercher_Click()
If UserForm2.Désignation.Text = "" Then
MsgBox "Vous devez saisir une Recherche", vbCritical
End If
Dim x As Long
ActiveSheet.Activate
For x = 4 To Range("A65535").End(xlUp).Row
If UCase(Range("A" & x)) Like "*" & UCase(UserForm2.Désignation.Value) & "*" Then
GoTo Trouve
Exit For
End If
Next x
GoTo Erreur
Exit Sub
Trouve: LigneActive = x
UserForm2.Désignation.Value = ActiveSheet.Cells(LigneActive, "A").Value
UserForm2.Entrée.Value = ActiveSheet.Cells(LigneActive, "D").Value
UserForm2.Puht.Value = ActiveSheet.Cells(LigneActive, "E").Value
UserForm2.Pvte.Value = ActiveSheet.Cells(LigneActive, "G").Value
UserForm2.Dlc.Value = ActiveSheet.Cells(LigneActive, "J").Value
UserForm2.TextBox_Stock.Value = ActiveSheet.Cells(LigneActive, "F").Value
UserForm2.TextBox_Etat.Value = ActiveSheet.Cells(LigneActive, "I").Value
UserForm2.TextBox_Sortie.Value = ActiveSheet.Cells(LigneActive, "H").Value
Exit Sub
Erreur: MsgBox ("Requête non trouvée !"), vbRetryCancel + vbExclamation
If Response = Retry Then
Désignation.Text = ""
Entrée.Text = ""
Puht.Text = ""
Pvte.Text = ""
Dlc.Text = ""
TextBox_Stock = ""
TextBox_Etat = ""
TextBox_Sortie = ""
Désignation.SetFocus
End If
End Sub |
Partager