Private Sub Worksheet_Change(ByVal Target As Range)
Dim dercol%, c As Range, deb As Range, s#, plage As Range, plagemax As Range, smax#
dercol = Cells(1, Columns.Count).End(xlToLeft).Column
Rows(1).Interior.ColorIndex = xlNone 'RAZ
For Each c In Cells(1).Resize(, dercol)
If Not IsNumeric(CStr(c)) Then Application.EnableEvents = False: c = 0: Application.EnableEvents = True
If deb Is Nothing Then If c <> 0 Then Set deb = c: s = 0
If Not deb Is Nothing Then
If c <> 0 Then
Set plage = Range(deb, c)
s = s + c
Else
If s > smax Then Set plagemax = plage: smax = s
Set deb = Nothing
s = 0
End If
End If
Next
If Not deb Is Nothing Then If s > smax Then Set plagemax = plage: smax = s
If Not plagemax Is Nothing Then plagemax.Interior.ColorIndex = 6 'jaune
ThisWorkbook.Names.Add "somme", smax 'nom défini
MsgBox "Somme maximum entre zéros " & [TEXT(somme,"[h]:mm")]
End Sub