Sub TirageAlé_a()
Dim DateDéb As Date, DateFin As Date, DateTirée As Date, LDéb As Long, LFin As Long, Le As Long, Ls As Long, i As Long
Dim coll As New Collection
Feuil2.Cells.ClearContents
DateDéb = CDate(InputBox("Date mini", "TirageAlé"))
DateFin = CDate(InputBox("Date maxi", "TirageAlé"))
LDéb = 2: LFin = Feuil1.Cells(Feuil1.Rows.Count, "A").End(xlUp).Row
i = 1
Randomize
'Do Until i = 200
While coll.Count < 5
Le = LDéb + Int(Rnd * (LFin - LDéb + 1))
If Feuil1.Cells(Le, "C").Value <> "" Then
DateTirée = CDate(Feuil1.Cells(Le, "B").Value)
If DateTirée >= DateDéb And DateTirée <= DateFin Then
On Error Resume Next
coll.Add DateTirée
On Error GoTo 0
cpt = 0
For n = DateTirée To CDate("30/" & Month(DateTirée) & "/" & Year(DateTirée))
Feuil2.Cells(i, "A").NumberFormat = Feuil1.Cells(Le, "A").NumberFormat
Feuil2.Cells(i, "A").Value = Feuil1.Cells(Le + cpt, "A").Value
Feuil2.Cells(i, "B").Value = Feuil1.Cells(Le + cpt, "B").Value
Feuil2.Cells(i, "C").Value = Feuil1.Cells(Le + cpt, "C").Value: Feuil1.Cells(Le + cpt, "C").ClearContents
Feuil1.Cells(Le + cpt, "D").Value = "Selectionnée"
i = i + 1
cpt = cpt + 1
Next n
End If
End If
Wend
'Loop
End Sub