Option Explicit: Option Base 1
'Calcul de la décote :
'Coef. 1 : "S" 0, "M" -0.5,"NS" -1
'Coef. 5 : "S" 0, "M" -2.5 ,"NS"-5
'Coef. 10 :"S" 0,"M" -5,"NS" -10
'Ou encore : "S" +Coef, "M" +Coef/2,"NS" +0
Sub Worksheet_Activate()
Dim DL%, i%, j%, T, T2, Num, Decote
Application.ScreenUpdating = False
DL = Sheets("Grille audit").Range("A65500").End(xlUp).Row
T = Sheets("Grille audit").Range("A3:F" & DL) ' Tableau des valeurs colonnes A à F
ReDim T2(9, 2) ' T2 tableau résultat, 1 total coef, 2 total notes
For i = 1 To UBound(T)
If T(i, 3) <> "" Then
Num = Val(Split(T(i, 1), ".")(0))
T2(Num, 1) = T2(Num, 1) + T(i, 3)
' Si "S" on ajoute le Coef, Si "M" on ajoute Coef/2, Si "NS" on ne rajoute rien
Select Case T(i, 4)
Case "S": T2(Num, 2) = T2(Num, 2) + T(i, 3)
Case "M": T2(Num, 2) = T2(Num, 2) + T(i, 3) / 2
End Select
End If
Next i
' Restitution des résultats
If T2(1, 1) <> 0 Then [C27] = T2(1, 2) / T2(1, 1)
If T2(2, 1) <> 0 Then [C28] = T2(2, 2) / T2(2, 1)
If T2(3, 1) <> 0 Then [C29] = T2(3, 2) / T2(3, 1)
If T2(4, 1) <> 0 Then [C30] = T2(4, 2) / T2(4, 1)
If T2(5, 1) <> 0 Then [G27] = T2(5, 2) / T2(5, 1)
If T2(6, 1) <> 0 Then [G28] = T2(6, 2) / T2(6, 1)
If T2(7, 1) <> 0 Then [G29] = T2(7, 2) / T2(7, 1)
If T2(8, 1) <> 0 Then [G30] = T2(8, 2) / T2(8, 1)
If T2(9, 1) <> 0 Then [C31] = T2(9, 2) / T2(9, 1)
End Sub