Bonjour, et merci de votre aide,
J’aimerai mettre un entête sur la listbox, mais je n’es pas pu y arrivé.
L’entête est sur : feuil2!A2:H2
Le code pour initialiser la UserForm
La listbox se rempli avec l’événement de changement d’une combobox
Voici le code
J’espère avoir votre aide
merci
J’aimerai mettre un entête sur la listbox, mais je n’es pas pu y arrivé.
L’entête est sur : feuil2!A2:H2
Le code pour initialiser la UserForm
Code:
Private Sub UserForm_Initialize()
With Me.ComboBox1
.ColumnCount = 2
.ColumnWidths = "60;0"
End With
With Me.ListBox1
.ColumnCount = 7
.ColumnWidths = "50;60;40;120;50;50;0"
End With
Me.CommandButton4.Enabled = False
Me.OptionButton1 = True
ListBox1.MultiSelect = 1
ListBox1.ListStyle = 1
End Sub
Voici le code
Code:
Private Sub ComboBox1_Change()
Dim i As Long, L As Long, Li As Long, k As Long
If ComboBox1.ListIndex > -1 Then
i = ComboBox1.ListIndex
Me.ListBox1.Clear
For L = 1 To UBound(Tbl)
If Tbl(L, 11) = "" Then
If Year(Tbl(L, ColDate)) = Val(Me.ComboBox2.Value) Then
If Val(Me.ComboBox1.List(i, 1)) = Month(Tbl(L, ColDate)) Then
With Me.ListBox1
.AddItem
.List(.ListCount - 1, 0) = Tbl(L, ColDate) 'date
.List(.ListCount - 1, 1) = ModeP 'effet ou prélèvement
.List(.ListCount - 1, 2) = Tbl(L, ColNumero) 'numéro ou n°
.List(.ListCount - 1, 3) = Tbl(L, ColFournisseur) 'bénéficiaire
.List(.ListCount - 1, 4) = Tbl(L, ColCause)
.List(.ListCount - 1, 5) = Tbl(L, ColMontant)
ListBox1.List(ListBox1.ListCount - 1, 6) = L + 3
End With
End If
End If
End If
Next L
End If
For C = 0 To ListBox1.ListCount - 1
ListBox1.Selected(C) = True
Next C
End Sub
J’espère avoir votre aide
merci