Ecrire une formule en une ligne

Bonsoir,

j'essaye de faire une listbox regroupant les résultats des recherches mais par contre, les résultats se mettent à la suite dans une colonne alors que je souhaiterai qu'ils soient en ligne.

Voilà mon code:

Private Sub TextBox1_Change()

    Application.ScreenUpdating = False

    Range("C2:C500").Interior.ColorIndex = 2
    ListBox1.Clear

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

End Sub

je pense que les mettre à la suite pourrait résoudre le "problème" mais j'ai essayé avec & " " & mais ça ne marche pas :/

vba ecell

Bonsoir

Essaie ce code

Private Sub TextBox1_Change()

  Application.ScreenUpdating = False

  Range("C2:C500").Interior.ColorIndex = 2
  ListBox1.Clear

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

End Sub

Merci beaucoup pour ton aide, ça fonctionne à merveille. J'avais essayé ce code mais j'ai du me tromper quelque part.

Bonne soirée.

Rechercher des sujets similaires à "ecrire formule ligne"