Sub Recherche()
Dim a(), d As New Dictionary, i As Long, an1 As Long, an2 As Long, Periode$
Application.ScreenUpdating = False
a = Worksheets("Commande").UsedRange.Value
Worksheets("Résultat").Range("A2:A100").ClearContents
an1 = Worksheets("Résultat").Range("B2").Value: an2 = Worksheets("Résultat").Range("C2").Value
Periode$ = Worksheets("Résultat").Range("D2").Value
For i = 2 To UBound(a)
If Year(a(i, 1)) = an1 And a(i, 11) = Periode Or Year(a(i, 1)) = an2 And a(i, 11) = Periode Then 'needed date
d(a(i, 5)) = a(i, 5)
End If
Next
If d.Count > 1 Then
Worksheets("Résultat").Range("A2").Resize(d.Count) = Application.Transpose(d.Items)
Else
Worksheets("Résultat").Range("A2").Value = d.Item(1)
End If
Worksheets("Résultat").Range("A2:A" & Worksheets("Résultat").Cells(Worksheets("Résultat").Rows.Count, "A").End(xlUp).Row).Sort key1:=Worksheets("Résultat").Range("A2"), order1:=xlAscending
Application.ScreenUpdating = True
End Sub