Sub FiltrerDernieresLignesColonne5()
' Créer un dictionnaire pour stocker les dernières lignes uniques de la colonne 5
Dim dernieresLignes As Object
Dim i As Long
Set dernieresLignes = CreateObject("Scripting.Dictionary")
' Parcourir les données pour obtenir les dernières lignes uniques
For i = ListBox1.ListCount - 1 To 0 Step -1
'refrence
Ref = ListBox1.List(i, 4)
'test si deja vu
If Not dernieresLignes.exists(Ref) Then
'mise en memoire
dernieresLignes.Add Ref, i
End If
Next i
' Parcourir le dictionnaire et ajouter les lignes correspondantes à la ListBox
Dim key As Variant
'ListBox1.Clear
For Each key In dernieresLignes.Keys
' Ajouter la ligne à la ListBox
ListBox1.AddItem ListBox1.List(dernieresLignes(key), 0)
ListBox1.List(ListBox1.ListCount - 1, 1) = ListBox1.List(dernieresLignes(key), 1)
ListBox1.List(ListBox1.ListCount - 1, 2) = ListBox1.List(dernieresLignes(key), 2)
ListBox1.List(ListBox1.ListCount - 1, 3) = ListBox1.List(dernieresLignes(key), 3)
ListBox1.List(ListBox1.ListCount - 1, 4) = ListBox1.List(dernieresLignes(key), 4)
Next key
End Sub