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 35
|
Sub rapprochement_Factures_BL()
nb_factures = Worksheets("Factures").Range("A65536").End(xlUp).Row ' on compte le nombre de lignes'
nb_BL = Worksheets("B_Livraison").Range("A65536").End(xlUp).Row
For ligne = 2 To nb_factures
'on lit le fournisseur'
Fournisseur = Trim(Worksheets("Factures").Cells(ligne, 2).Value)
'on lit la date'
Dat = FormatDateTime(Worksheets("Factures").Cells(ligne, 3).Value)
Dat2 = FormatDateTime(Worksheets("B_Livraison").Cells(ligne, 3).Value)
With Worksheets("B_Livraison").Range("B2:B" & CStr(nb_BL))
Set cellule = .Find(What:=Fournisseur, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not cellule Is Nothing Then
prem_occurence = cellule.Row
Do
If Worksheets("B_Livraison").Cells(cellule.Row, 2).Value = Fournisseur And Dat2 = Dat 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
End If
Set cellule = .FindNext(cellule)
Loop While Not cellule Is Nothing And cellule.Row <> prem_occurence
End If
End With
Next
End Sub |
Partager