Private Sub ComboBox1_Change()
PeuplerListbox ComboBox1.Text
End Sub
Private Sub UserForm_Initialize()
Me.Label3.Caption = Date
Me.ComboBox1 = "Choisir un type de client ..."
Me.ComboBox1.List = Array("*", "Créancier", "Débiteur")
PeuplerListbox
End Sub
Sub PeuplerListbox(Optional Critere)
Dim t, i&, n&, som&, crit, v
ListBox1.Clear: TextBox1 =""
ListBox1.ColumnCount = 5
With Feuil1
t = .Range("a2:e" & .Cells(.Rows.Count, "a").End(xlUp).Row)
If IsMissing(Critere) Then crit = "*" Else crit = Critere
For i = 1 To UBound(t)
If t(i, 3) Like crit Then
som = som + t(i, 5)
n = n + 1
End If
Next i
If n > 0 Then
ReDim v(1 To n, 1 To UBound(t, 2))
n = 0
For i = 1 To UBound(t)
If t(i, 3) Like crit Then
n = n + 1
For j = 1 To UBound(t, 2): v(n, j) = t(i, j): Next
End If
Next i
ListBox1.List = v
TextBox1 = Format(som, "#, ##")
End If
End With
End Sub