1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Sub Test()
With Sheets("historique commandes")
If CBool(SerchXls(.Columns("D:D"), .Range("D1"), numerodecommande.Value, True, False)) Then
MsgBox "Le numéro de commande est déja utilisé."
numerodecommande.Value = ""
End If
End With
End Sub
Function SerchXls(Myrange As Range, MyCellule As Range, strRecherche, EntierCell As Boolean, EnBoucle As Boolean) As Long '
On Error Resume Next
SerchXls = 0
If EntierCell = False Then Entier = xlPart Else Entier = xlWhole
SerchXls = Myrange.Cells.Find(What:=strRecherche, After:=MyCellule, LookIn:=xlFormulas, LookAt _
:=Entier, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=EntierCell).Row
If SerchXls <= MyCellule.Row And EnBoucle = False Then SerchXls = 0
End Function |
Partager