Recherche intuitive listbox

Bonsoir chers tous

Je voudrais rechercher via textbox et afficher dans listbox de facon intuitive.

J'ai reçu un code pour un listbox à une colonne qui marche bien. mais je voudrais l'appliquer à un listbox multicolonne .

Merci !!!

16recherche.xlsm (29.08 Ko)

Bonsoir KTM, bonsoir le forum,

Peut-être comme ça :

Private Sub TextBox14_Change()
Dim t(), i&, a&, j&, L&

With TextBox14
    If .Value = "" Then
        ListBox1.List = tbl
    Else
        For i = 1 To UBound(tbl, 1)
            For j = 1 To UBound(tbl, 2)
                If Opt1 Then    'si on choisi commence par on teste le debut des chaines
                    If tbl(i, j) Like .Value & "*" Then
                        a = a + 1
                        ReDim Preserve t(1 To UBound(tbl, 2), 1 To a)
                        For L = 1 To UBound(tbl, 2)
                            t(L, a) = tbl(i, L)
                        Next L
                        Exit For
                    End If
                Else    'sinon on regarde partout dans les chaines
                    If tbl(i, j) Like "*" & .Value & "*" Then
                        a = a + 1
                        ReDim Preserve t(1 To UBound(tbl, 2), 1 To a)
                        For L = 1 To UBound(tbl, 2)
                            t(L, a) = tbl(i, L)
                        Next L
                        Exit For
                    End If
                End If
            Next j
        Next i
        Select Case a
            Case 0
                ListBox1.Clear
            Case 1
                ListBox1.Column = Application.Transpose(t)
            Case Else
                ListBox1.List = Application.Transpose(t)
        End Select
    End If
End With
End Sub

Mais en faisant comme ça tu pourras voir les changements en cliquant sur les boutons d'option après avoir tapé le texte :

15ktm-ep-v01.xlsm (28.06 Ko)

SUPER !!!

MERCI

Rechercher des sujets similaires à "recherche intuitive listbox"