Since you are varying both rows and columns, try using INDEX/MATCH
In M20 copied across and down

=IF(LEN(INDEX($D$3:$R$8, MATCH($J20,$A$3:$A$8,0),MATCH($L$16, $D$1:$R$1,0)+COLUMNS($A$1:A$1)-1))>0,1,"")
Does that work for you?