I believe that:
=SUM(B1:B5)-SUMPRODUCT((ISNUMBER(SEARCH(TRANSPOSE(myRange),A1:A5)))*B1:B5)
array-entered will do that.