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
| Private Sub CommandButton5_Click()
Dim M As Long, nbLignes As Long
Dim Source As Worksheet
Dim Trouve As Boolean
Set Source = Sheets("FACTURATION")
nbLignes = Source.Cells(Rows.Count, "B").End(xlUp).Row
' Recherche les valeurs entrées dans txtCommentaire et txtContacte
For M = 1 To nbLignes
If LCase(Source.Range("B" & M)) = LCase(TextBoxaffaire.Value) And LCase(Source.Range("C" & M)) = LCase(FrmSaisie.TextBoxbat.Value) Then
Trouve = True
FrmSaisie.TextBoxcontact.Text = Source.Cells(M, 3).Value
FrmSaisie.TextBoxnom.Text = Source.Cells(M, 4).Value
FrmSaisie.ComboBoxmatiere.Text = Source.Cells(M, 5).Value
FrmSaisie.TextBoxlargeur.Value = Source.Cells(M, 6).Value
FrmSaisie.TextBoxhauteur.Value = Source.Cells(M, 7).Value
FrmSaisie.TextBoxquantite.Value = Source.Cells(M, 8).Value
FrmSaisie.ComboBoxforme.Text = Source.Cells(M, 7).Value
FrmSaisie.ComboBoxfinition.Value = Source.Cells(M, 9).Value
FrmSaisie.ComboBoxaccessoires.Value = Source.Cells(M, 10).Value
FrmSaisie.TextBoxcommentaire.Value = Source.Cells(M, 11).Value
Exit For
End If
Next
If Not Trouve Then
MsgBox "Aucun BAT correspondant trouvé"
End If
Set Source = Nothing
End Sub |
Partager