Re : Problème sur initialisation listbox
bonjour Géraldine
à la fin de UserForm_Initialize
tu as
'initialize Listbox2 sur famille
CheckBox1 = True
' Label7.Caption = LabelText & Sheets("Article").Cells(9, Col) '"CODE FAMILLE"
'MaCollection Col 'module 2 liste sans doublons
ligne mise en commentaires,déjà fait par checkbox1
'IniListbox2
end sub
'changer l'ini de la plage,et l'ini de coldata
Sub MaCollection(Col)
Dim Fin As Long, J As Long, K As Long, L As Long, Choix As Byte
Dim ColData As New Collection, Item As Variant
Dim Plage As Range, Cel As Range, Swap1, Swap2
'Application.ScreenUpdating = False ' LIGNE "EFFET" ?
'Sheets("Article").Activate
With Sheets("Article")
Fin = .Cells(.Rows.Count, 4).End(xlUp).Row
Set Plage = .Range(.Cells(10, Col), .Cells(Fin, Col))
End With
'INITIALISATION DE LA PLAGE DES VALEURS SITUÉES EN COLONNE Col
For Each Cel In Plage
'Contient cellules uniques
On Error Resume Next
ColData.Add Cel.Value, CStr(Cel.Value)
On Error GoTo 0
Next Cel
' Tri de la collection (optionnel,mettre en commentaires entre '* et '**)
'*
For K = 1 To ColData.Count - 1
For J = K + 1 To ColData.Count
If ColData(K) > ColData(J) Then
Swap1 = ColData(K)
Swap2 = ColData(J)
ColData.Add Swap1, before:=J
ColData.Add Swap2, before:=K
ColData.Remove K + 1
ColData.Remove J + 1
End If
Next J
Next K
'**
'End If
'Next L
L = 0
ReDim Liste(1 To ColData.Count)
For Each Item In ColData
L = L + 1
Liste(L) = Item
Next Item
Set Plage = Nothing
End Sub
à bientôt