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 36 37 38 39 40 41 42 43 44
| Sub Comparer_pru()
Dim lastrow As Integer, i As Integer
Dim cr1 As Range
Dim cr As Long
Dim TD As String, PA As String, PL As String
Dim CodeAcomparer As Variant
Dim B As Worksheet
Dim D As Worksheet
Application.ScreenUpdating = False
Set B = Worksheets("BASE")
Set D = Worksheets("DATA")
lastrow = D.Range("D1").End(xlDown).Row
For i = 2 To lastrow
CodeAcomparer = D.Cells(i, 4).Value
Set cr1 = B.Range("G:G").Find(CodeAcomparer, LookIn:=xlValues)
cr = cr1.Row
If B.Cells(cr, 7).Value = D.Cells(i, 4).Value And B.Cells(cr, 44).Value = D.Cells(i, 26).Value Then
D.Cells(i, 27).Value = "stable"
ElseIf B.Cells(cr, 7).Value = D.Cells(i, 4).Value And B.Cells(cr, 44).Value <> D.Cells(i, 26).Value Then
If B.Cells(cr, 22).Value <> D.Cells(i, 16).Value Then
TD = " Taux de douane différent "
Else
TD = " "
End If
If B.Cells(cr, 11).Value <> D.Cells(i, 8).Value Then
PA = " Prix d'achat différent "
Else
PA = " "
End If
If B.Cells(cr, 15).Value <> D.Cells(i, 11).Value Then
PL = " Préstation logistique différente "
Else
PL = " "
End If
D.Cells(i, 27) = TD & PA & PL
End If
Next i
End Sub |
Partager