Not 100% sure I understand but:
L4:
=MATCH(L$5,Sheet2!$C$4:$D$4,0)
M5:
=INDEX(Sheet2!$4:$10,COLUMNS($M5:M5),$L$4)
copied across to S5
L4 is simply to avoid repetitive calcs.
If in reality the values being retrieved are always numeric then you can use SUMIF also:
M5:
=SUMIF(Sheet2!$B$4:$B$10,M$4,INDEX(Sheet2!$C$4:$D$10,0,MATCH(LOOKUP(REPT("Z",255),$B5:L5),Sheet2!$C$3:$D$3,0)))
copied to S5
Using the SUMIF method M5:S5 can be simply copied and pasted over C5:I5 to replicate results without need for modification
(L4 calc is not nec. in relation to SUMIF method)
In short the SUMIF approach is pretty flexible
Bookmarks