Is this what you are looking for?

=SUM($F$10:$F$19)
+SUMPRODUCT(--(NOT(COUNTIF($E$10:$E$19,$A$10:$A$19)>0)),$B$10:$B$19)
+SUMPRODUCT(($F$10:$F$19="")*(SUMIF($A$10:$A$19,$E$10:$E$19,$B$10:$B$19)))
I just added onto p45cal's formula to pick up the missing bits (as I understand it).