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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| Option Explicit
Sub pricer1()
Dim i, n, m, poli As Double
Dim taux_grele, taux_temp, taux_arc
Dim rdt_par, rdt_ha, superf, prix_uni, capital_par, prime_grele, prime_temp, prime_arc, prime_totale_grele, prime_totale_temp, prime_totale_arc As Double
Dim donnees As Range
Dim recherche_taux As String
Sheets("Automatisé").Range("A:Z").ClearContents
Application.ScreenUpdating = False
'donnees = Sheets("PRICER1_2017").Range("AD2:AF1048576")
Sheets("Automatisé").Range("a1").Value = "Police"
Sheets("Automatisé").Range("c1").Value = "Prime Grêle"
Sheets("Automatisé").Range("e1").Value = "Prime Tempête"
Sheets("Automatisé").Range("g1").Value = "Prime ARC"
'n = Sheets("PRICER1_2017").Cells(Rows.Count, 1).End(xlUp).Row
n = 15
For i = 1 To 1
'Retient le numéro de police
poli = Sheets("PRICER1_2017").Cells(i + 1, 1).Value
'Recherche de la clé
recherche_taux = Sheets("PRICER1_2017").Cells(i + 1, 27).Value & "-" & Sheets("PRICER1_2017").Cells(i + 1, 22).Value & "-" & Sheets("PRICER1_2017").Cells(i + 1, 18).Value
'Taux grêle
taux_grele = Application.VLookup(recherche_taux, Sheets("PRICER1_2017").Range("ad2:ah142387"), 3, 0)
'Taux tempête
taux_temp = Application.VLookup(recherche_taux, Sheets("PRICER1_2017").Range("ad2:ah142387"), 4, 0)
'Taux arc
taux_arc = Application.VLookup(recherche_taux, Sheets("PRICER1_2017").Range("ad2:ah142387"), 5, 0)
' Sheets("Automatisé").Cells(i + 1, 1).Value = recherche_taux
' Sheets("Automatisé").Cells(i + 1, 2).Value = taux_grele
'Calcul capital assuré
rdt_par = Sheets("PRICER1_2017").Cells(i + 1, 20).Value
superf = Sheets("PRICER1_2017").Cells(i + 1, 19).Value
rdt_ha = (rdt_par / superf) * 100
prix_uni = Sheets("PRICER1_2017").Cells(i + 1, 31).Value
capital_par = rdt_par * prix_uni
'Prime grêle
prime_grele = capital_par * taux_grele / 100
'Prime tempête
prime_temp = capital_par * taux_temp / 100
'Prime arc
prime_arc = capital_par * taux_arc / 100
'affectation du numéro de police dans la nouvelle feuille
Sheets("Automatisé").Cells(i + 1, 1).Value = poli
'affectation des primes
Sheets("Automatisé").Cells(i + 1, 3).Value = prime_grele
Sheets("Automatisé").Cells(i + 1, 5).Value = prime_temp
Sheets("Automatisé").Cells(i + 1, 7).Value = prime_arc
Next i
Sheets("Automatisé").Range("i1").Value = "Prime totale Grêle"
Sheets("Automatisé").Range("k1").Value = "Prime totale Tempête"
Sheets("Automatisé").Range("m1").Value = "Prime totale ARC"
'prime_totale_grele = WorksheetFunction.SumIfs(Sheets("Automatisé").Range("C:C").Value, Sheets("Automatisé").Range("A:A").Value, Sheets("Automatisé").Range("A:A").Value)
'prime_totale_temp = WorksheetFunction.SumIfs(Sheets("Automatisé").Range("E:E").Value, Sheets("Automatisé").Range("A:A").Value, Sheets("Automatisé").Range("A:A").Value)
'prime_totale_arc = WorksheetFunction.SumIfs(Sheets("Automatisé").Range("G:G").Value, Sheets("Automatisé").Range("A:A").Value, Sheets("Automatisé").Range("A:A").Value)
For i = 1 To n
prime_totale_grele = WorksheetFunction.SumIfs(Sheets("Automatisé").Range("C1:C10"), Range("'Automatisé'!A1:A10"), Range("'Automatisé'!A1:A10"))
prime_totale_temp = WorksheetFunction.SumIfs(Range("'Automatisé'!E1:E10").Value, Range("'Automatisé'!A1:A10").Value, Range("'Automatisé'!A1:A10").Value)
prime_totale_arc = WorksheetFunction.SumIfs(Range("'Automatisé'!G1:G10").Value, Range("'Automatisé'!A1:A10").Value, Range("'Automatisé'!A1:A10").Value)
Sheets("Automatisé").Cells(i + 1, 9).Value = prime_totale_grele
Sheets("Automatisé").Cells(i + 1, 11).Value = prime_totale_temp
Sheets("Automatisé").Cells(i + 1, 13).Value = prime_totale_arc
Next i
Application.ScreenUpdating = True
End Sub |
Partager