XL 2019 rechercher à partir de userform en plusieurs feuilles

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Dadi147

XLDnaute Occasionnel
Bonjour, j'ai créé un userform pour rechercher des résultats dans un tableau dans Sheet1. Pouvez-vous m'aider pour que je puisse rechercher avec les mêmes critères dans plusieurs feuilles Excel qui incluent le même tableau mais avec une valeur différente ?
 

Pièces jointes

Solution
Bonjour

il te suffit de boucler sur les feuilles
VB:
Private Sub ComboBox1_Change()
Sheet1.Range("i1") = ComboBox1.Text
TextBox1.Value = Sheet1.Range("I2").Value
Dim a
Dim i As Long
Me.ComboBox1.Text = StrConv(Me.ComboBox1.Text, vbProperCase)
Me.ListBox1.Clear
For Each ws In ActiveWorkbook.Sheets
    With ws
        For i = 3 To Application.WorksheetFunction.CountA(.Range("A:A"))
            a = Len(Me.ComboBox1.Text)
            If Left(.Cells(i, 4).Value, a) = Left(Me.ComboBox1.Text, a) Then
                Me.ListBox1.AddItem .Cells(i, 1).Value
                Me.ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(i, 2).Value
                Me.ListBox1.List(ListBox1.ListCount - 1, 2) = .Cells(i, 3).Value...
Bonjour

il te suffit de boucler sur les feuilles
VB:
Private Sub ComboBox1_Change()
Sheet1.Range("i1") = ComboBox1.Text
TextBox1.Value = Sheet1.Range("I2").Value
Dim a
Dim i As Long
Me.ComboBox1.Text = StrConv(Me.ComboBox1.Text, vbProperCase)
Me.ListBox1.Clear
For Each ws In ActiveWorkbook.Sheets
    With ws
        For i = 3 To Application.WorksheetFunction.CountA(.Range("A:A"))
            a = Len(Me.ComboBox1.Text)
            If Left(.Cells(i, 4).Value, a) = Left(Me.ComboBox1.Text, a) Then
                Me.ListBox1.AddItem .Cells(i, 1).Value
                Me.ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(i, 2).Value
                Me.ListBox1.List(ListBox1.ListCount - 1, 2) = .Cells(i, 3).Value
                Me.ListBox1.List(ListBox1.ListCount - 1, 3) = .Cells(i, 4).Value
                Me.ListBox1.List(ListBox1.ListCount - 1, 4) = .Cells(i, 5).Value
                Me.ListBox1.List(ListBox1.ListCount - 1, 5) = .Cells(i, 6).Value
                Me.ListBox1.List(ListBox1.ListCount - 1, 6) = .Cells(i, 7).Value
                Me.ListBox1.List(ListBox1.ListCount - 1, 7) = .Cells(i, 8).Value
                Me.ListBox1.List(ListBox1.ListCount - 1, 8) = .Cells(i, 9).Value
                Me.ListBox1.List(ListBox1.ListCount - 1, 9) = .Cells(i, 10).Value
            End If
        Next i
    End With
Next ws
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Retour