Trier une ListeBox qui fonctionne sur une ComboBox mais pas sur les autres

Bonjour à tous,

Sur mon Fichier, j'ai plusieurs ComboBox qui me servent à sortir une liste sur une ListBox.

Sauf que je veux que cette ListBox soit trié quand elle s'affiche.

Voici le code de ma 1ere ComboBox :

Private Sub ComboBox1_Click()
Dim PlageLB As Range, i As Integer
With Sheets("Filtrage")
.Range("B2") = ComboBox1.Value
If .Range("AF4").Value = 1 Then
Set f = Sheets("Filtrage")
    Set MonDico = CreateObject("Scripting.Dictionary")
  a = f.Range("AA7:AA" & f.[AA1500].End(xlUp).Row) ' tableau a(n,1) pour rapidité
  For i = LBound(a) To UBound(a)
    If a(i, 1) <> "" Then MonDico(a(i, 1)) = ""
  Next i
  Me.ComboBox2.List = MonDico.keys
Set f = Sheets("Filtrage")
    Set MonDico = CreateObject("Scripting.Dictionary")
  a = f.Range("Z7:Z" & f.[Z1500].End(xlUp).Row) ' tableau a(n,1) pour rapidité
  For i = LBound(a) To UBound(a)
    If a(i, 1) <> "" Then MonDico(a(i, 1)) = ""
  Next i
  Me.ComboBox3.List = MonDico.keys

    If .Range("AF4") = 0 Or .Range("AF4") = 1 Then Set PlageLB = .Range("Y6:AF1500")
    If .Range("AN4") = 2 Then Set PlageLB = .Range("AG6:AN1500")
    If .Range("AV4") = 3 Then Set PlageLB = .Range("AO6:AV1500")
    If .Range("BD4") = 4 Then Set PlageLB = .Range("AW6:BD1500")
    If Not PlageLB Is Nothing Then
        With ListBox1
            .List = PlageLB.Value
            For i = .ListCount - 1 To 0 Step -1
                If .List(i) = "" Then
                    .RemoveItem (i)
                Else
                    .List(i, 7) = Format(.List(i, 7), "0.00 €")
                End If
            Next i
        End With
        Call TriCol
    End If

End If
If .Range("AN4").Value = 2 Then
Set f = Sheets("Filtrage")
    Set MonDico = CreateObject("Scripting.Dictionary")
  a = f.Range("AI7:AI" & f.[AI1500].End(xlUp).Row) ' tableau a(n,1) pour rapidité
  For i = LBound(a) To UBound(a)
    If a(i, 1) <> "" Then MonDico(a(i, 1)) = ""
  Next i
  Me.ComboBox2.List = MonDico.keys
Set f = Sheets("Filtrage")
    Set MonDico = CreateObject("Scripting.Dictionary")
  a = f.Range("AH7:AH" & f.[AH1500].End(xlUp).Row) ' tableau a(n,1) pour rapidité
  For i = LBound(a) To UBound(a)
    If a(i, 1) <> "" Then MonDico(a(i, 1)) = ""
  Next i
  Me.ComboBox3.List = MonDico.keys

    If .Range("AF4") = 0 Or .Range("AF4") = 1 Then Set PlageLB = .Range("Y6:AF1500")
    If .Range("AN4") = 2 Then Set PlageLB = .Range("AG6:AN1500")
    If .Range("AV4") = 3 Then Set PlageLB = .Range("AO6:AV1500")
    If .Range("BD4") = 4 Then Set PlageLB = .Range("AW6:BD1500")
    If Not PlageLB Is Nothing Then
        With ListBox1
            .List = PlageLB.Value
            For i = .ListCount - 1 To 0 Step -1
                If .List(i) = "" Then
                    .RemoveItem (i)
                Else
                    .List(i, 7) = Format(.List(i, 7), "0.00 €")
                End If
            Next i
        End With
        Call TriCol
    End If

End If
If .Range("AV4").Value = 3 Then
Set f = Sheets("Filtrage")
    Set MonDico = CreateObject("Scripting.Dictionary")
  a = f.Range("AQ7:AQ" & f.[AQ1500].End(xlUp).Row) ' tableau a(n,1) pour rapidité
  For i = LBound(a) To UBound(a)
    If a(i, 1) <> "" Then MonDico(a(i, 1)) = ""
  Next i
  Me.ComboBox2.List = MonDico.keys
Set f = Sheets("Filtrage")
    Set MonDico = CreateObject("Scripting.Dictionary")
  a = f.Range("AP7:AP" & f.[AP1500].End(xlUp).Row) ' tableau a(n,1) pour rapidité
  For i = LBound(a) To UBound(a)
    If a(i, 1) <> "" Then MonDico(a(i, 1)) = ""
  Next i
  Me.ComboBox3.List = MonDico.keys

    If .Range("AF4") = 0 Or .Range("AF4") = 1 Then Set PlageLB = .Range("Y6:AF1500")
    If .Range("AN4") = 2 Then Set PlageLB = .Range("AG6:AN1500")
    If .Range("AV4") = 3 Then Set PlageLB = .Range("AO6:AV1500")
    If .Range("BD4") = 4 Then Set PlageLB = .Range("AW6:BD1500")
    If Not PlageLB Is Nothing Then
        With ListBox1
            .List = PlageLB.Value
            For i = .ListCount - 1 To 0 Step -1
                If .List(i) = "" Then
                    .RemoveItem (i)
                Else
                    .List(i, 7) = Format(.List(i, 7), "0.00 €")
                End If
            Next i
        End With
        Call TriCol
    End If

End If
If .Range("BD4").Value = 4 Then
Set f = Sheets("Filtrage")
    Set MonDico = CreateObject("Scripting.Dictionary")
  a = f.Range("AY7:AY" & f.[AY1500].End(xlUp).Row) ' tableau a(n,1) pour rapidité
  For i = LBound(a) To UBound(a)
    If a(i, 1) <> "" Then MonDico(a(i, 1)) = ""
  Next i
  Me.ComboBox2.List = MonDico.keys
Set f = Sheets("Filtrage")
    Set MonDico = CreateObject("Scripting.Dictionary")
  a = f.Range("AZ7:AZ" & f.[AZ1500].End(xlUp).Row) ' tableau a(n,1) pour rapidité
  For i = LBound(a) To UBound(a)
    If a(i, 1) <> "" Then MonDico(a(i, 1)) = ""
  Next i
  Me.ComboBox3.List = MonDico.keys

    If .Range("AF4") = 0 Or .Range("AF4") = 1 Then Set PlageLB = .Range("Y6:AF1500")
    If .Range("AN4") = 2 Then Set PlageLB = .Range("AG6:AN1500")
    If .Range("AV4") = 3 Then Set PlageLB = .Range("AO6:AV1500")
    If .Range("BD4") = 4 Then Set PlageLB = .Range("AW6:BD1500")
    If Not PlageLB Is Nothing Then
        With ListBox1
            .List = PlageLB.Value
            For i = .ListCount - 1 To 0 Step -1
                If .List(i) = "" Then
                    .RemoveItem (i)
                Else
                    .List(i, 7) = Format(.List(i, 7), "0.00 €")
                End If
            Next i
        End With
        Call TriCol
    End If

End If
End With

End Sub

Le trie se fait parfaitement grâce à "Call TriCol" qui a le code suivant:

Sub TriCol()
Dim TMP0 As Variant
Dim TMP1 As Variant
Dim TMP2 As Variant
Dim TMP3 As Variant
Dim TMP4 As Variant
Dim TMP5 As Variant
Dim TMP6 As Variant
Dim TMP7 As Variant
Dim i As Integer
Dim j As Integer
With UserForm1.ListBox1
    For i = 1 To .ListCount - 1
        For j = 1 To .ListCount - 1
            If CStr(.List(i, 6)) < CStr(.List(j, 6)) Then
                TMP0 = .List(i, 0): .List(i, 0) = .List(j, 0): .List(j, 0) = TMP0
                TMP1 = .List(i, 1): .List(i, 1) = .List(j, 1): .List(j, 1) = TMP1
                TMP2 = .List(i, 2): .List(i, 2) = .List(j, 2): .List(j, 2) = TMP2
                TMP3 = .List(i, 3): .List(i, 3) = .List(j, 3): .List(j, 3) = TMP3
                TMP4 = .List(i, 4): .List(i, 4) = .List(j, 4): .List(j, 4) = TMP4
                TMP5 = .List(i, 5): .List(i, 5) = .List(j, 5): .List(j, 5) = TMP5
                TMP6 = .List(i, 6): .List(i, 6) = .List(j, 6): .List(j, 6) = TMP6
                TMP7 = .List(i, 7): .List(i, 7) = .List(j, 7): .List(j, 7) = TMP7
            End If
        Next j
    Next i
End With
End Sub

Sauf que j'ai exactement le même code sur la ComboBox2 et le "TriCol" ne s'effectue pas et donc ma ListBox n'est pas trié.

Pouvez-vous m'aider s'il vous plait?

Rechercher des sujets similaires à "trier listebox qui fonctionne combobox pas"