Sub Test()
Dim rg As Range, c As Range, cRef As Range
Dim Somme As Double, TempSomme As Double
Set rg = Range("L4:L" & Range("L" & Rows.Count).End(xlUp).Row)
For Each c In rg
If c.Offset(0, -3) = 31 Then
Set cRef = c
TempSomme = c.Value
Somme = 0
If c.Offset(0, 7) = "" Then c.Offset(0, 7) = "4A"
Set c = c.Offset(1, 0)
Do Until c.Offset(0, -3) = 31 Or IsEmpty(c)
Somme = Somme + c.Value
c.Offset(0, -3) = 40
If c.Offset(0, 7) = "" Then c.Offset(0, 7) = "4A"
Set c = c.Offset(1, 0)
Loop
If Somme <> TempSomme Then cRef.Interior.ColorIndex = 3
End If
Next c
End Sub