1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| Sub test()
Dim LigneTrouve As Long
LigneTrouve = RechercheDoubleEntre(Sheets("Feuil2").Range("A:A"), "Commande 1253", "Article 5623", "C")
If CBool(LigneTrouve) Then MsgBox "Trouvé en ligne " & LigneTrouve
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
Function RechercheDoubleEntre(Plage As Range, ChercheTxt1 As String, ChercheTxt2 As String, ColCherche2 As String) As Long
Dim L As Long: L = 1
Do While L > 0
L = SerchXls(Plage, Plage.Cells(L, 1), ChercheTxt1, True, False)
If Not CBool(L) Then Exit Do
If Plage.Parent.Cells(L, ColCherche2) = ChercheTxt2 Then Exit Do
Loop
RechercheDoubleEntre = L
End Function |
Partager