Est ce possible de faire 2 boucles For...Each ?

Bonjour le forum

J'essaie d'adapter 2 boucles For Each. Une boucle pour des combinaisons à rechercher

dans une autre liste.

J'ai essayé aussi en concaténant la liste de recherche sans succès.

Je vous joins un fichier exemple de ce que j'aimerais obtenir.

Merci de votre aide!

Bonjour,

une proposition

Sub calcul_test()

    'dernière ligne colonne A
    DernLigne = Range("A" & Rows.Count).End(xlUp).Row
    derlg = Range("Y" & Rows.Count).End(xlUp).Row
    'dernière colonne ligne 2
    'DernColonne = Cells(2, Cells.Columns.Count - 1).End(xlToLeft).Column - 1
    DernColonne = 22
    'DerCol = Cells(1, Cells.Columns.Count - 1).End(xlToLeft).Column - 24
    DerCol = 25
    Range("Z2:AA" & derlg).ClearContents
    Set maPlage = Range(Cells(2, 3), Cells(DernLigne, DernColonne))
    Set combi = Range(Cells(2, DerCol), Cells(derlg, DerCol))
    For Each r In maPlage.Rows
        For Each i In combi
            t = Split(i.Value, " ")
            nb = UBound(t) + IIf(LBound(t) = 0, 1, 0)
            flag = 0
            For Each c In r.Cells
                For k = LBound(t) To UBound(t)
                    If t(k) + 0 = c.Value Then flag = flag + 1: Exit For
                Next k
            Next
            If flag = nb Then
                lig = i.Row
                Cells(lig, 26) = Cells(lig, 26) + 1
                Cells(lig, 27) = Cells(lig, 27) & IIf(Cells(lig, 27) = "", "", ",") & r.Row - 1
            End If
        Next
    Next
End Sub

Bonsoir à tous

h2so4...EXCELLENT TRAVAIL

Le code fonctionne très bien.

Merci !

Rechercher des sujets similaires à "possible boucles each"