Option Explicit
Private Sub Workbook_Open()
Dim a As Range
Dim cell As Range
With Sheets("MONDES")
Intersect(.[7:100], .Cells.SpecialCells(xlCellTypeConstants, 2)).Name = "Pays"
End With
With [Pays].Offset(, 2)
.NumberFormat = """+""0;-0;"
For Each cell In .Cells
cell.Value = CalculerDifferenceHeure(cell.Offset(0, -1), Sheets("MONDES").Range("Q2"))
Next cell
End With
End Sub
Function CalculerDifferenceHeure(R7 As Range, Q2 As Range) As String
If R7.Value = Q2.Value Then
CalculerDifferenceHeure = ""
ElseIf R7.Value > Q2.Value Then
CalculerDifferenceHeure = "+" & Format(R7.Value - Q2.Value, "h")
Else
CalculerDifferenceHeure = "-" & Format(Q2.Value - R7.Value, "h")
End If
End Function