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
| Sub rapprochement_Factures_BL()
nb_factures = Worksheets("Factures").Range("C65536").End(xlUp).Row ' on se base syur la colonne C pour le calcul du nombre de ligne
nb_BL = Worksheets("B_Livraison").Range("C65536").End(xlUp).Row
For ligne = 2 To nb_factures
'on lit le transporteur
transport = Trim(Worksheets("Factures").Cells(ligne, 2).Value)
quant = Worksheets("Factures").Cells(ligne, 5).Value
Montant = Worksheets("Factures").Cells(ligne, 6).Value
With Worksheets("B_Livraison").Range("B2:B" & CStr(nb_BL))
Set cellule = .Find(What:=transport, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not cellule Is Nothing Then
prem_occurence = cellule.Row
trouvé = false
Do
If Worksheets("B_Livraison").Cells(cellule.Row, 5).Value = quant And _
Worksheets("B_Livraison").Cells(cellule.Row, 6).Value = Montant Then
' on a trouvé , on indique
Worksheets("B_Livraison").Cells(cellule.Row, 7).Value = " Rapprochement OK"
Worksheets("B_Livraison").Cells(cellule.Row, 8).Value = Worksheets("Factures").Cells(ligne, 1).Value
Worksheets("Factures").Cells(ligne, 7).Value = " Rapprochement OK"
Worksheets("Factures").Cells(ligne, 8).Value = Worksheets("B_Livraison").Cells(cellule.Row, 1).Value
trouvé = true
End If
Set cellule = .FindNext(cellule)
Loop While Not cellule Is Nothing And cellule.Row <> prem_occurence and trouvé = false
End If
End With
Next |
Partager