Champ de Recherche

Bonjour,

J'ai au classeur excel qui a 400 lignes un champ de recherche

Option Compare Text

Private Sub TextBox1_Change()

    'www.excel-pratique.com/fr/astuces_vba/champ-de-recherche-vba

    Application.ScreenUpdating = False

    Range("E7:E400").Interior.ColorIndex = 2

    If TextBox1 <> "" Then
        For ligne = 7 To 400
            If Cells(ligne, 5) Like "*" & TextBox1 & "*" Then
                Cells(ligne, 5).Interior.ColorIndex = 43

            End If
        Next
    End If

End Sub

et je voudrai que le résultat de la recherche arrive de suite sur le nom rechercher.

Merci de votre réponse et de votre aide.

bonjour,

tu peux essayer comme ça : (non testé)

Private Sub TextBox1_Change()
    Application.ScreenUpdating = False
    Range("E7:E400").Interior.ColorIndex = 2
    If TextBox1 <> "" Then
        For ligne = 7 To 400
            If Cells(ligne, 5) Like "*" & TextBox1 & "*" Then
                Cells(ligne, 5).Interior.ColorIndex = 43
               ActiveWindow.ScrollRow = ligne
               Exit For
            End If
        Next
    End If
End Sub

A+

Bonsoir,

très bien ça marche nikel

mais je voudrai aussi, si possible, que le résultat de la recherche arrive de suite sur la ligne complète avec une autre couleur.

Merci de votre réponse et de votre aide.

5recherche.xlsm (72.45 Ko)

Une possibilité :

Private Sub TextBox1_Change()
    Application.ScreenUpdating = False
    Range(Cells(7, 1), Cells(400, 7)).Interior.ColorIndex = xlNone
    If TextBox1 <> "" Then
        For ligne = 7 To 400
            If Cells(ligne, 5) Like "*" & TextBox1 & "*" Then
            Range(Cells(ligne, 1), Cells(ligne, 7)).Interior.ColorIndex = 43
               ActiveWindow.ScrollRow = ligne
               Exit For
            End If
        Next
    End If
End Sub

A+

Bonjour,

merci de votre aide

ça marche nickel.

Rechercher des sujets similaires à "champ recherche"