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
| Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim x As Integer, last_line As Integer
last_line = Cells(Rows.Count, 1).End(xlUp).Row
If Not Intersect(Target, Range(Cells(13, 7), Cells(last_line, 9))) Is Nothing Then
For i = 13 To last_line
Points = 0
points_sauvegardés = 0
points_non_sauvegardés = 0
propres_points = Feuil2.Cells(i, 9)
points_accordés = Feuil2.Cells(i, 8)
point_de_sauvegarde = Feuil2.Cells(i, 7)
points_suspendus = 0
If propres_points <= points_accordés Then
Points = propres_points
points_sauvegardés = Points
If Points > point_de_sauvegarde Then
points_sauvegardés = point_de_sauvegarde
points_non_sauvegardés = propres_points - point_de_sauvegarde
Points = points_sauvegardés + points_non_sauvegardés
End If
Else
'propres_points >points_accordés
If propres_points > point_de_sauvegarde Then
If points_accordés > point_de_sauvegarde Then
points_sauvegardés = point_de_sauvegarde
points_non_sauvegardés = points_accordés - points_sauvegardés
Points = points_sauvegardés + points_non_sauvegardés
End If
If points_accordés <= point_de_sauvegarde Then
points_sauvegardés = points_accordés
points_non_sauvegardés = 0
Points = points_sauvegardés + points_non_sauvegardés
End If
End If
If propres_points <= point_de_sauvegarde Then
points_sauvegardés = propres_points
points_non_sauvegardés = 0
Points = points_sauvegardés + points_non_sauvegardés
End If
End If
If propres_points > Points Then
points_suspendus = propres_points - Points
Else
points_suspendus = 0
End If
Feuil2.Cells(i, 10) = Points
Feuil2.Cells(i, 11) = points_sauvegardés
Feuil2.Cells(i, 12) = points_non_sauvegardés
Feuil2.Cells(i, 13) = points_suspendus
Next i
End If
End Sub |
Partager