XL 2010 modification vba textbox recherche

jokerfidelio

XLDnaute Occasionnel
Bonjour a tous,

j'aurais besoin de votre aide pour modifier un code VBA concernant une recherche.
je n'arrive pas a adapter celui ci pour que la recherche soit sur les colonne 3 , 6 et 9
ici :
If Cells(ligne, 1) Like "*" & TextBox1 & "*" Then
Cells(ligne, 1).Interior.ColorIndex = 43
ListBox1.AddItem Cells(ligne, 1)

idem pour Range("A2:A24") il faudrait que je puisse ajouter en plus : de C3 a C24 de F3 a F24 et de I3 a I24

Voici le code :

Option Compare Text

Private Sub TextBox1_Change()

Application.ScreenUpdating = False

Range("A2:A24").Interior.ColorIndex = 2
ListBox1.Clear

If TextBox1 <> "" Then
For ligne = 2 To 24
If Cells(ligne, 1) Like "*" & TextBox1 & "*" Then
Cells(ligne, 1).Interior.ColorIndex = 43
ListBox1.AddItem Cells(ligne, 1)
End If
Next
End If

End Sub

merci d'avance pour votre aide, si précieuse...
 
Dernière édition:

jokerfidelio

XLDnaute Occasionnel
Résolu......

Code:
Option Compare Text
Private Sub TextBox1_Change()
    Application.ScreenUpdating = False
    Range("C3:C24, F3:F24, I3:I24").Interior.ColorIndex = 2
    ListBox1.Clear
    liste_colonnes = Array(3, 6, 9, 10) 'C F I J

    If TextBox1 <> "" Then
        For ligne = 2 To 24
            For no_colonne = 0 To UBound(liste_colonnes)
                colonne = liste_colonnes(no_colonne)
                If Cells(ligne, colonne) Like "*" & TextBox1 & "*" Then
                    Cells(ligne, colonne).Interior.ColorIndex = 43
                    ListBox1.AddItem Cells(ligne, colonne)
                End If
            Next
        Next
    End If
End Sub
 

Discussions similaires

Statistiques des forums

Discussions
314 017
Messages
2 104 582
Membres
109 083
dernier inscrit
Stef06