Private Sub Worksheet_Change(ByVal Target As Range)
Dim j%, jours%, cel%, inter%
Dim p%, x%, L%, S%, cpt%, cell As Range
If Not Intersect(Target, Range("R7:W46")) Is Nothing Then Exit Sub
If Not Intersect(Target, Range("C42:W47")) Is Nothing Then Exit Sub
For j = 3 To 15 Step 3
If Cells(Target.Row, j).Value = "x" Then
M = M + 3
End If
Next j
Cells(Target.Row, 18).Value = M
For j = 4 To 16 Step 3
If Cells(Target.Row, j).Value = "x" Then
C = C + 2
End If
Next j
Cells(Target.Row, 19).Value = C
For j = 5 To 14 Step 3
If Cells(Target.Row, j).Value = "x" Then
AM = AM + 4
End If
Next j
If Cells(Target.Row, 17).Value = "x" Then AM = AM + 3
Cells(Target.Row, 20).Value = AM
'verif pour les jours
jours = 0
For k = 3 To 17 Step 3
cel = 0
For j = 0 To 2
If Cells(Target.Row, k + j).Value = "x" Then
cel = cel + 1
End If
Next j
If cel = 3 Then jours = jours + 1
Next k
If jours > 0 Then
Cells(Target.Row, 18) = Cells(Target.Row, 18) - 3 * jours
Cells(Target.Row, 19) = Cells(Target.Row, 19) - 2 * jours
If Cells(Target.Row, 17).Value = "x" Then
inter = Cells(Target.Row, 20) - 4 * (jours - 1)
Cells(Target.Row, 20) = inter - 3
Else
Cells(Target.Row, 20) = Cells(Target.Row, 20) - 4 * jours
End If
End If
Cells(Target.Row, 21).Value = jours
'Calcul des Sous-Totaux
For L = 1 To 5
cpt = cpt + 1
For p = 3 To 17
x = 0
For S = 6 + cpt To 41 Step 5
If LCase(Cells(S, p).Value) = "x" Then x = x + 1
Next S
Cells(41 + cpt, p).Value = x
Next p
Next L
'Calcule des Sous-Totaux : Total Heure et Total Jours
cpt = 0
For L = 1 To 5
cpt = cpt + 1
For p = 18 To 21
x = 0
For S = 6 + cpt To 41 Step 5
x = Cells(S, p).Value + x
Next S
Cells(41 + cpt, p).Value = x
Next p
Next L
'Calcul des Totaux
For p = 3 To 17
x = 0
For Each cell In Range(Cells(7, p).Address(0, 0), Cells(41, p).Address(0, 0))
If LCase(cell) = "x" Then x = x + 1
Next cell
Cells(47, p).Value = x
Next p
'Calcule des Totaux : Total Heure et Total Jours
For L = 18 To 21
x = 0
For p = 42 To 46
x = Cells(p, L).Value + x
Next p
Cells(47, L).Value = x
Next L
End Sub