Bonjour,
Il suffit d'utiliser l'enregistreur de macro (faut-il encore que la formule soit juste, dans votre cas, INDEX doit couvrir les 3 colonnes du tableau et pas uniquement la colonne C) et glisser le résultat dans une macro.
Range("E10").FormulaArray = "=INDEX(R8C1:R20C3,MATCH(1,(R8C1:R20C1=R6C5)*(R8C2:R20C2=R7C5),0),3)"
ou bien une fonction personnalisée:
en E10: formule: =RecherchePrix(A9:A20;E6;E7)
le code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Function RecherchePrix(PlageRef As Range, Ref As String, Nb As Range) As Long
Range("E10").ClearContents
DerLig = Range("A" & Rows.Count).End(xlUp).Row
r = Application.Match(Ref, PlageRef, 0) + 8
If r <> 0 Then
i = r - 1
Do
i = i + 1
If Cells(i, "A") = Ref And Cells(i, "B") = Nb Then
RecherchePrix = Cells(i, "C")
Exit Function
End If
Loop While i <= DerLig And Cells(i, "B") <> Nb
End If
End Function |
Cdlt
Partager