Sub recap()
Dim MaCollection As New Collection ' pour éviter les doublons
Dim TheDate As Date ' Déclare les variables.
Dim Msg, Reponse
Dim c As Long, n As Long
Dim LigDeb As Long, LigFin As Long
Windows("base en projet.xls").Activate
Range("A1").Select
Reponse = InputBox("Entrez une date (jj/mm/aaaa)", "Listing contrôle depuis le... ", Sheets("base").Range("A1"))
If IsDate(Reponse) Then
TheDate = Reponse
UserForm3.Label2 = Date - DateDiff("d", TheDate, Now)
UserForm3.Caption = "Récapitulatif des contrôles depuis le :" & TheDate
UserForm3.CommandButton2.Caption = "Mise en page du récapitulatif des contrôles depuis le: " & UserForm3.Label2.Caption
LigFin = Worksheets("base").Range("A65536").End(xlUp).Row + 1
For n = 1 To LigFin
If Worksheets("base").Range("A" & n) = CDate(UserForm3.Label2) Then
LigDeb = n
Exit For
End If
Next n
If n = LigFin + 1 Then
MsgBox ("La date n'existe pas!")
Call recap
Else
For n = LigDeb To LigFin
On Error Resume Next
MaCollection.Add "item", Worksheets("base").Range("A" & n).Text
If Err.Number = 0 Then
With UserForm3.ListBox1
.AddItem Worksheets("base").Range("a" & n).Text 'date
.List(.ListCount, 1) = Worksheets("base").Range("b" & n + LigDeb - 1) 'nom
.List(.ListCount, 2) = Worksheets("base").Range("c" & n + LigDeb - 1) 'immat
End With
End If
On Error GoTo 0
Next n
UserForm3.Show
'UserForm3.CommandButton2_Click
End If
Else
If Reponse = "" Then
Exit Sub
Else
MsgBox ("Format date incorrect!")
Call recap
End If
End If
End Sub