Paul, i think that for 1 more time you need SUMPRODUCT.

=SUMPRODUCT(($B$2:$B$49=$B52)*($A$2:$A$49=C$51)*($C$1:$AT$1=$B$51)*($C$2:$AT$49))