1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| 'ColDeb est le N° de la colonne d'une feuille de calcul
'LigDeb la première ligne à prendre en compte.
'NBcol le nombre de colonne(s) de la listeBox
'Mémorise le numéro de la ligne où se trouve la donnée dans la dernière colonne,
'ce qui sert à retrouver l'emplacement dans la feuille de calcul, si ensuite la liste est triée.
Sub RempliListMultiColonneSansDoublon2007(LstBx As msforms.ListBox, F As Worksheet, _
ColDeb As Long, Optional LigDeb As Long = 1, Optional NBcol As Long = 1)
Dim Dico, Lig As Long, Clum As Integer, Cel As Range
Set Dico = CreateObject("Scripting.Dictionary")
With LstBx
.ColumnCount = NBcol + 1
For Lig = LigDeb To F.Cells(65536, ColDeb).End(xlUp).Row
Set Cel = F.Cells(Lig, ColDeb)
If Not Dico.Exists(Cel.Value) Then
Dico.Add Cel.Value, Cel.Value
LstBx.AddItem
For Clum = 0 To NBcol - 1
LstBx.List(LstBx.ListCount - 1, Clum) = Cel.Offset(0, Clum)
Next Clum
LstBx.List(LstBx.ListCount - 1, Clum) = Cel.Row
End If
Next Lig
End With
End Sub |
Partager