Simpler to use SUMIF, I think. Try this formula in I7

=SUMIF(L$7:O$37,H7,M$7:P$37)+SUM(C7:E7)

format as general and copy down