1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Function Calcul(DateDeb As Date, Datefin As Date)
Dim Ctr As Date
For i = Int(DateDeb) To Int(Datefin)
If Weekday(i, 2) < 6 Then
If i = Int(DateDeb) Then
If Int(DateDeb) <> Int(Datefin) Then
Ctr = #8:00:00 PM# - Application.Max(#8:00:00 AM#, TimeSerial(Hour(DateDeb), Minute(DateDeb), Second(DateDeb)))
Else
Ctr = Application.Min(TimeSerial(Hour(Datefin), Minute(Datefin), Second(DateDeb)), #8:00:00 PM#) _
- Application.Max(#8:00:00 AM#, TimeSerial(Hour(DateDeb), Minute(DateDeb), Second(DateDeb)))
End If
ElseIf i < Int(Datefin) Then
Ctr = Ctr + 0.5
Else
Ctr = Ctr + Application.Min(TimeSerial(Hour(Datefin), Minute(Datefin), Second(DateDeb)), #8:00:00 PM#) - #8:00:00 AM#
End If
End If
Next i
Calcul = Ctr
End Function |
Partager