Bonjour,
une correction de ton code
Option Explicit
Public Sub Create_calendar()
Dim lo As ListObject, lo2 As ListObject
Dim rCell As Range, Cell As Range, rng As Range
Dim dt As Date, dt2 As Date
'-------------------------------------------------
Dim d As Double, n As Double
'-------------------------------------------------
With ActiveSheet
Set lo = .ListObjects("T_date")
Set lo2 = .ListObjects("T_horaire")
End With
With lo2
If Not .DataBodyRange Is Nothing Then .DataBodyRange.Delete
Set rCell = .InsertRowRange.Cells(2)
End With
For Each Cell In lo.ListColumns(2).DataBodyRange
dt = Cell.Value: dt2 = Cell.Offset(, 1)
d = Cell.Offset(, 3)
n = dt2 - dt + 1
rCell.Value = dt
Set rng = rCell.Resize(n)
With rng
.DataSeries Type:=3, Date:=1, stop:=dt2
.Offset(, 1).Value = d
End With
Set rCell = lo2.HeaderRowRange.Cells(2).Offset(lo2.ListRows.Count + 1)
Next Cell
With lo2
.Sort.SortFields.Add .ListColumns(2).DataBodyRange, xlSortOnValues, xlAscending
.Sort.Apply
.Sort.SortFields.Clear
End With
End Sub