Function HProduction(deb#, fin#, t1#, t2#, t3#, t4#, fer As Range)
Dim n&, datheure#, dat&, test As Boolean, heure#, minutes&
t1 = Application.Round(t1, 6): t2 = Application.Round(t2, 6)
t3 = Application.Round(t3, 6): t4 = Application.Round(t4, 6)
For n = 1440 * deb To 1440 * fin
datheure = n / 1440
If Int(CDec(datheure)) > dat Then
dat = Int(CDec(datheure))
test = Weekday(dat, 2) < 6 And Application.CountIf(fer, dat) = 0
End If
heure = Application.Round(datheure - dat, 6)
If test And (heure > t1 And heure <= t2 Or heure > t3 And heure <= t4) Then minutes = minutes + 1
Next
HProduction = minutes / 1440
End Function