Option Explicit
Sub Calculator()
Dim WB As Workbook
Dim WSBD As Worksheet, WSTarif As Worksheet
Dim RangeBd As Range, RangeTarif As Range
Dim CellBD As Range, CellTarif As Range
Set WB = ThisWorkbook
Set WSBD = WB.Worksheets("BD")
Set WSTarif = WB.Worksheets("TARIF")
Set RangeBd = WSBD.Range("A2:A" & WSBD.Range("A1000").End(xlUp).Row)
Set RangeTarif = WSTarif.Range("A2:A" & WSTarif.Range("A1000").End(xlUp).Row)
For Each CellBD In RangeBd
For Each CellTarif In RangeTarif
If CellTarif = CellBD.Offset(0, 14) Then
If CellBD.Offset(0, 15) = "" Then 'P = vide
If CellTarif.Offset(0, 2) = 0 Then
CellBD.Offset(0, 19) = CellTarif.Offset(0, 1) + CellBD.Offset(0, 16)
Else
CellBD.Offset(0, 19) = CellTarif.Offset(0, 1) + (CellTarif.Offset(0, 2) * CellBD.Offset(0, 9)) + CellBD.Offset(0, 16)
End If
Else
CellBD.Offset(0, 19) = CellBD.Offset(0, 15) + CellBD.Offset(0, 16)
End If
End If
Next CellTarif
If (CellBD.Offset(0, 13) / CellBD.Offset(0, 9)) < 0.9 Then
CellBD.Offset(0, 19) = CellBD.Offset(0, 19) - 20
End If
Next CellBD
End Sub