Sub Cricris()
Dim tablo()
Dim C As Range, Dte As Range
Dim X As Long, K As Long, i As Integer, Z As Integer
X = 1
With Sheets("Feuil1")
For K = 3 To .Range("B65536").End(xlUp).Row
ReDim Preserve tablo(3, 1 To X)
tablo(0, X) = .Cells(K, 2)
tablo(1, X) = .Cells(K, 5)
tablo(2, X) = .Cells(K, 6) - .Cells(K, 5)
tablo(3, X) = .Cells(K, 6)
X = X + 1
Next
End With
For Z = 1 To UBound(tablo, 2)
If CDate(tablo(1, Z)) < "01/06/2008" Then
MsgBox "Date " & tablo(1, Z) & " hors période pour : " & tablo(0, Z), vbInformation, "Erreur sur les dates"
Exit Sub
End If
If CDate(tablo(3, Z)) > "30/09/2008" Then
MsgBox "Date " & tablo(3, Z) & " hors période pour : " & tablo(0, Z), vbInformation, "Erreur sur les dates"
Exit Sub
End If
Next
With Sheets("Feuil2")
.Range("C3:DA20") = ""
For i = 1 To UBound(tablo, 2)
Set C = .Range("B3:B20").Find(tablo(0, i))
If Not C Is Nothing Then
Set Dte = .Range("C2:DA2").Find(tablo(1, i))
If Not Dte Is Nothing Then
.Range(.Cells(C.Row, Dte.Column), .Cells(C.Row, Dte.Column).Offset(0, tablo(2, i))) = "1"
End If
End If
Set C = Nothing
Set Dte = Nothing
Next
End With
End Sub