Bonjour,
déjà vous vérifier si le TexBox1 est vide
If UserForm1.TextBox1 = Empty Then
pour vérifier si ce numéro est présent dans la colonne Q (Référence pièce)
If Not IsError(Application.Match(Val(UserForm1.TextBox1), sh1.Range("Q:Q"), 0)) Then
vErreur = 1
vMessageErreur = vMessageErreur + Chr(10) + "LE NUMERO DE CHEQUE EST DÉJÀ UTILISÉ"
Else
Err.Clear
End If
aussi essayez d'éviter les .Select et Selection
par exemple
Dim sh1 'déclaration dans le haut de la macro
Set sh1 = Sheets("Fichier Remboursements")
With sh1
.Cells(LastRw, 1) = "SIEGE"
.Cells(LastRw, 2) = UserForm1.listboxchoixbanque.Value
.Cells(LastRw, 3) = Date
.Cells(LastRw, 4) = Date
.Cells(LastRw, 5) = "RBT" & " " & UserForm1.listboxchoixcaf.Value & " " & UserForm1.ComboBox1.Value & "/" & UserForm1.ComboBox2.Value & " " & UserForm1.ListBoxcaf.Value
.Cells(LastRw, 6) = "BQ"
.Cells(LastRw, 7) = "46710000"
.Cells(LastRw, 8) = "X"
.Cells(LastRw, 9) = Application.VLookup(UserForm1.ListBoxcaf.Value, Range("caf"), 2, False)
.Cells(LastRw, 10) = Date
.Cells(LastRw, 11) = UserForm1.Textmontant.Value 'Référence écriture
.Cells(LastRw, 12) = "RBT" & " " & UserForm1.listboxchoixcaf.Value & " " & UserForm1.ComboBox1.Value & "/" & UserForm1.ComboBox2.Value & " " & UserForm1.ListBoxcaf.Value
.Cells(LastRw, 13) = "" 'Mode reglement
.Cells(LastRw, 14) = "D"
.Cells(LastRw, 15) = UserForm1.Textmontant.Value
.Cells(LastRw, 16) = "N"
.Cells(LastRw, 17) = UserForm1.TextBox1.Value 'no. cheque
.Cells(LastRw, 18) = "EUR"
End With