Re : vba Excel afficher une liste triée dans une combobox
Bonjour à tous,
Béber, je te remercie encore pour ton bout de code. J'essaie maintenant de l'adapter suivant plusieurs critères (c'est à dire plusieurs checkbox). Ca fonctionne bien, le seul hic est que la liste qu'il m'affiche dans ma combobox est entre coupée de 2 lignes, c'est à dire qu'il me crée des lignes blanches.
Pouvez-vous me dire où se situe mon erreur SVP?
Je joins mon fichier si jamais cela peut aider.
Merci encore.
Voici mon bout de code
Sub plat()
Dim i, L As Integer
Dim Cell As Range, Rng As Range, Crit As String
Dim Tbl As Variant
If Feuil10.CheckBox5.Value = True Then
Crit = "légume"
End If
'
If Feuil10.CheckBox6.Value = True Then
Crit = "poisson"
End If
'
If Feuil10.CheckBox7.Value = True Then
Crit = "viande"
End If
'
If Feuil10.CheckBox1.Value = True Then
Crit = "autre"
End If
With Feuil8
.Activate
Set Rng = Feuil8.Range("F2", [D64000].End(xlUp))
If Not Feuil8.AutoFilterMode Then
Feuil8.Range("A1").AutoFilter
End If
Feuil8.Range("A1").AutoFilter Field:=7, Criteria1:=Crit
Set Rng = Rng.SpecialCells(xlCellTypeVisible)
End With
ReDim Tbl(0 To Rng.Count - 1)
For Each Cell In Rng
Tbl(i) = Cell.Value
i = i + 1
Next
Feuil10.ComboBox2.Clear
Feuil10.ComboBox2.List = Tbl
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData 'supprime le filtrage
End If
Feuil10.Select
End Sub