Sub test()
Dim Tabl, c As Range, d As Range, e As Range, dmin As Long, dmax As Long, t As Long
With Sheets("Etat des locations")
Sheets("Détail").Activate
Sheets("Détail").Range("3:1000").ClearContents
Set c = .Range("C5")
dmin = WorksheetFunction.Min(.Range("H5:H" & .Range("H65536").End(xlUp).Row))
dmax = WorksheetFunction.Max(.Range("I5:I" & .Range("I65536").End(xlUp).Row))
Set d = Sheets("Détail").Range("B3")
d.Offset(-2).Resize(2, Sheets("ressources").Range("B4:B" & Sheets("ressources").Range("B65536").End(xlUp).Row).Count) = Application.Transpose(Sheets("ressources").Range("B4:C" & Sheets("ressources").Range("B65536").End(xlUp).Row).Value)
d.Offset(, -1) = dmin
d.Offset(, -1).NumberFormat = "dd/mm/yy"
d.Offset(, -1).AutoFill d.Offset(, -1).Resize(dmax - dmin + 1)
l = d.Offset(65500, -1).End(xlUp).Row - 2
m = d.Offset(-2, 250).End(xlToLeft).Column - 1
For t = 1 To m
d.Offset(0, t - 1).Resize(l) = Cells(2, d.Offset(0, t - 1).Column)
Next
Do While .Cells(c.Row, 2) <> ""
For t = 1 To l
If Int(.Cells(c.Row, 8)) = Int(d.Offset(t - 1, -1)) Then
Do While c.Column < 8
If c <> "" Then
For Each e In d.Offset(t - 1, c.Column - 3).Resize(.Cells(c.Row, 9) - .Cells(c.Row, 8) + 1)
e = e - c
Next e
End If
Set c = c(1, 2)
Loop
Set c = .Cells(c.Row + 1, 3)
End If
Next t
Loop
End With
End Sub