try (untested)

in B38
=SUMIF(b1:b33,"="&$a38)

copy down and across as far as D41