Je rajoute ça :
Dim a_converted, b_converted, a_hours, a_minutes, a_seconds, b_hours, b_minutes, b_seconds As Long
Dim Rest_time, Start_work, End_work, Evening_rest, Morning_rest, Midnight As Long
d = DateDiff("d", a, b)
'Correcting factors with schedule from 09:00 to 18:00.
a_hours = Hour(a)
a_minutes = Minute(a)
a_seconds = Second(a)
a_converted = a_hours * 3600 + a_minutes * 60 + a_seconds
b_hours = Hour(b)
b_minutes = Minute(b)
b_seconds = Second(b)
b_converted = b_hours * 3600 + b_minutes * 60 + b_seconds
Rest_time = 54000 'Rest time of 15 hours = 54000 secs.
Start_work = 32400 '9 hours converted in seconds.
End_work = 64800 '18 hours converted in seconds.
Evening_rest = 21600 'Time from 18 hours to 24 hours.
Morning_rest = 32400 'Time from 00 hours to 9 hours.
Midnight = 86400 'Midnight o'clock.
Factor = 0
Factor_a = 0
Factor_b = 0
If (a_converted >= Start_work & a_converted <= End_work) & (b_converted >= Start_work & b_converted <= End_work) Then
Factor = d