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
| Sub tarif()
'
Dim ligne_1 As Integer '1 correspond à la page de liste des clients
Dim ligne_2 As Integer '2 correspond à la page "base"
Dim ligne_inter As Integer
Dim forfait As Integer
Dim forfaitDepart As Integer
Dim coeff As Double
Dim prix As Double 'prix est le tarif appliqué au client (prix = forfait * coefficient)
ligne_1 = 7
ligne_2 = 2
forfaitDepart = 165
Do While (Sheets("Liste_clients").Cells(ligne_1, 1) <> "")
Sheets("Liste_clients").Select
If (Cells(ligne_1, 1).Value <> "") Then
For ligne_2 = 2 To 34
ligne_inter = ligne_2 - 1
If ((Sheets("Liste_clients").Cells(ligne_1, 2).Value) <= 20) Then
forfait = forfaitDepart
Else
If (((Sheets("Liste_clients").Cells(ligne_1, 2).Value) <= (Sheets("Base").Cells(ligne_2, 1).Value)) And ((Sheets("Liste_clients").Cells(ligne_1, 2).Value) > (Sheets("Base").Cells(ligne_inter, 1).Value))) Then
forfait = Sheets("Base").Cells(ligne_2, 2).Value
End If
End If
ligne_2 = ligne_2 + 1
Next ligne_2
For ligne_2 = 2 To 96
If ((Sheets("Liste_clients").Cells(ligne_1, 3).Value) = (Sheets("Base").Cells(ligne_2, 4).Value)) Then
coeff = Sheets("Base").Cells(ligne_2, 5).Value
End If
Next ligne_2
prix = coeff * forfait
Sheets("Liste_clients").Cells(ligne_1, 5).Value = prix
ligne_1 = ligne_1 + 1
End If
Loop
'
End Sub |
Partager