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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| Option Explicit
Private Sub Cbb_Catégorie_Change()
Dim ro&, cel As Range
ListBox_Articles.Clear
Txt_Detail = ""
With Cbb_Catégorie
For Each cel In Sheets("Articles").Range("F2", Cells(Rows.Count, "F").End(xlUp)).Cells
If cel.Value = .Value Then
ro = cel.Row
With ListBox_Articles
.AddItem cel.Row
.List(.ListCount - 1, 1) = Format(Sheets("Articles").Cells(ro, "B"), "dd/mm/yyyy")
.List(.ListCount - 1, 2) = Sheets("Articles").Cells(ro, "C")
.List(.ListCount - 1, 3) = Sheets("Articles").Cells(ro, "E")
.List(.ListCount - 1, 4) = Sheets("Articles").Cells(ro, "F")
End With
End If
Next
End With
End Sub
'
Private Sub ListBox_Articles_Change()
Dim ligne
With ListBox_Articles
If .ListCount > 0 Then
ligne = .List(.ListIndex, 0)
Txt_Detail = Sheets("Articles").Cells(ligne, "D")
End If
End With
End Sub
'
Private Sub UserForm_Initialize()
Dim I&, J&, strTemp$
Me.Cbb_Catégorie.List = Workbooks(ThisWorkbook.Name).Sheets("Variables").[L_Catégorie_Article].Value
' 'Tri le contenu du ComboBox par ordre alphabétique
With Me.Cbb_Catégorie
For I = 0 To .ListCount - 1
For J = 0 To .ListCount - 1
If .List(I) < .List(J) Then
strTemp = .List(I)
.List(I) = .List(J)
.List(J) = strTemp
End If
Next J
Next I
End With
' les Withs des colonnes de la listbox_articles
With ListBox_Articles
.ColumnCount = 5
.ColumnWidths = "15;70;200;100;150"
'remplacer 15 par 0 si on veut pas voir la colonne 0 qui contient les indexs de lignes du sheets pour les items
End With
End Sub |
Partager