Sub CreerHoraire()
'l'horaire n'est pas entré le vendredi après-midi
Dim PremCel As Range, deb, fin, t1, t2, t3, t4, tablo(), i&
Set PremCel = [A2] '1ère cellule, à adapter
deb = DateValue("1/1/2010") 'à adapter
fin = DateValue("31/12/2020") 'à adapter
t1 = TimeValue("8:0") 'à adapter
t2 = TimeValue("12:0") 'à adapter
t3 = TimeValue("13:15") 'à adapter
t4 = TimeValue("17:0") 'à adapter
If PremCel <> "" Then If MsgBox(PremCel.Address(0, 0) & " est déjà renseignée, voulez-vous continuer ?", 52) = 7 Then Exit Sub
ReDim tablo(1 To fin - deb + 1, 1 To 6)
tablo(1, 1) = deb
For i = 1 To UBound(tablo)
If i > 1 Then tablo(i, 1) = tablo(i - 1, 1) + 1
If Weekday(tablo(i, 1), 2) < 6 And Application.CountIf([Feries], tablo(i, 1)) = 0 Then
tablo(i, 2) = t1: tablo(i, 3) = t2
If Weekday(tablo(i, 1), 2) < 5 Then tablo(i, 4) = t3: tablo(i, 5) = t4
End If
tablo(i, 6) = "=RC[-3]-RC[-4]+RC[-1]-RC[-2]"
Next
PremCel.Resize(UBound(tablo), 6) = tablo
End Sub