Try
Formula: copy to clipboard
=COUNTIFS(Sheet1!$A$2:$A$16,A2,INDEX(Sheet1!$B$2:$N$16,,MATCH(B1,Sheet1!$B$1:$N$1,0)),"<>0")