Rechercher les entêtes de colonne en fonction 1 critère

Bonjour

Je cherche une façon d'afficher toutes les entêtes de mon tableau correspondantes à un critère donné pour une ligne choisit. Dans le fichier joint je veux trouver si une pièce (a ou b ou c ou d ou e) est présente dans quels outils (1,2,3,4,5,6). La cellule A10 me permettrait de choisir la pièce (dans ce cas-ci pièce d) et les outils dans lesquels cette pièce est présente serait afficher dans les cellules C10, C11 et suivantes (dans ce cas-ci outil 2, outil 4 et outil 6). Prenez note que le fichier original a environ 250 colonnes et 1500 lignes.

Avez-vous une solution à me proposer?

Merci

13test-recherche.xls (13.50 Ko)

Bonjour,

Une proposition à tester.

15test-recherche.zip (14.53 Ko)
Option Explicit
Option Private Module
Public Sub RechercheOutils()
Dim wss As Worksheet, wsd As Worksheet
Dim lngRow As Long, d As Long
Dim iCol As Integer, i As Integer
Dim rng As Range, c As Range
Dim myArray

    Application.ScreenUpdating = False
    Set wss = Worksheets("Données")
    Set wsd = Worksheets("Recherche")

    With wsd
        If .[A2] = Empty Then Exit Sub
        .Range("C2:C" & .Range("C2").End(xlDown).Row).ClearContents
    End With

    With wss
        lngRow = .Range("A" & Rows.Count).End(xlUp).Row
        iCol = .Cells(1, Columns.Count).End(xlToLeft).Column
        Set rng = .Range(.Cells(1, 1), .Cells(lngRow, iCol))
        Set myArray = CreateObject("Scripting.Dictionary")

        Set c = rng.Find(what:=wsd.[A2], LookIn:=xlValues, lookat:=xlWhole)
        If Not c Is Nothing Then
            d = c.Row
        End If

        For i = 2 To iCol
            If Not IsEmpty(.Cells(d, i)) Then myArray(.Cells(1, i).Value) = ""
        Next
    End With

    With wsd
        .[C2].Resize(myArray.Count, 1) = Application.Transpose(myArray.keys)
    End With

    Set wss = Nothing: Set wsd = Nothing: Set rng = Nothing: Set myArray = Nothing

End Sub

Bonjour

MERCI, c'est exactement ce dont j'ai besoin. Je n'ai pas encore pris le temps de comprendre l'ensemble du code que tu m'as envoyé mais suffisamment pour l'adapter à mon fichier réel et ça fonctionne très bien. Je commence tout juste à utiliser des macros et j'étais complètement bloqué pour celle-ci.

Merci pour ton aide.

Rechercher des sujets similaires à "rechercher entetes colonne fonction critere"