If you want the count then use this as an array formula

Enter + control + Shift then drag down

=SUMPRODUCT(IF(--(Sheet1!$A$2:$A$20=Sheet2!$D6)*--(Sheet1!$B$2:$B$20=$E6)*INDEX(Sheet1!$D$2:$O$20,,MATCH($F6,Sheet1!$D$1:$O$1,0))>0,1,0))