Compter les items d'une listbox

Bonsoir,

SVP est ce que possible de calculer le nombre des items dans la listbox en détail ?

Merci.

Exemple:

sans titre
201.xlsm (31.33 Ko)

Bonjour,

Il y a plusieurs façons d'écrire cet ajout au code ...

Note : dans ton exemple > l'ordre des TextBox de B est 6,7,8,5 >

Je les ai ordonnés 5,6,7 et 8 ...

Un essai ...

Private Sub Cmd_rech_Click()
Dim dic_liste As Object
Dim i As Integer
Dim sel_ligne As Boolean
Dim A As Integer, B As Integer
Dim Acc As Integer, Bcc As Integer
Dim Add As Integer, Bdd As Integer
Dim Aacc As Integer, Bacc As Integer

    '// création d'un dictionnaire relatif aux lignes sélectionnées de la feuille active
    Set dic_liste = CreateObject("Scripting.Dictionary")
    i = 2
    While Cells(i, "A") <> Empty
        sel_ligne = True
        If Me.Cbx_service <> Empty Then If Cells(i, "F") <> Me.Cbx_service Then sel_ligne = False
        If Me.Cbx_type <> Empty Then If Cells(i, "E") <> Me.Cbx_type Then sel_ligne = False
        If Me.Cbx_date_entrée <> Empty Then If Not Cells(i, "D") >= CDate(Me.Cbx_date_entrée) Then sel_ligne = False
        If Me.Cbx_date_sortie <> Empty Then If Not Cells(i, "D") <= CDate(Me.Cbx_date_sortie) Then sel_ligne = False

        If sel_ligne Then
            dic_liste(i) = Range(Cells(i, "A"), Cells(i, "G")).Value
            If Cells(i, "F") = "A" Then
                A = A + 1
                If Cells(i, "F") = "A" And Cells(i, "F").Offset(, -1) = "CC" Then Acc = Acc + 1
                If Cells(i, "F") = "A" And Cells(i, "F").Offset(, -1) = "DD" Then Add = Add + 1
                If Cells(i, "F") = "A" And Cells(i, "F").Offset(, -1) = "ACC" Then Aacc = Aacc + 1
            End If
            If Cells(i, "F") = "B" Then
                B = B + 1
                If Cells(i, "F") = "B" And Cells(i, "F").Offset(, -1) = "CC" Then Bcc = Bcc + 1
                If Cells(i, "F") = "B" And Cells(i, "F").Offset(, -1) = "DD" Then Bdd = Bdd + 1
                If Cells(i, "F") = "B" And Cells(i, "F").Offset(, -1) = "ACC" Then Bacc = Bacc + 1
            End If
        End If

        i = i + 1
    Wend

    '// affichage lignes sélectionnées de la feuille active
    Me.ListBox1.Clear
    If dic_liste.Count > 0 Then Me.ListBox1.Column = Application.Transpose(dic_liste.items)

    Me.TextBox1 = A
    Me.TextBox2 = Acc
    Me.TextBox3 = Add
    Me.TextBox4 = Aacc
    Me.TextBox5 = B
    Me.TextBox6 = Bcc
    Me.TextBox7 = Bdd
    Me.TextBox8 = Bacc
End Sub

ric

Un grand merci à vous ric,

Vous m'avez vraiment aidé

Bonne soirée.

Rechercher des sujets similaires à "compter items listbox"