Here is the formula:
=IF(E35 = "NO",IF(E34 = "NO",(VLOOKUP(E33, {Costs - Costing Sheet Range 9},2, false)),(VLOOKUP(E33, {Costs - Costing Sheet Range 9},3, false))), SUMIFS(VLOOKUP(E33,{Costs - Costing Sheet Range 9},4,false),IF(E34 = "NO",(VLOOKUP(E33, {Costs - Costing Sheet Range 9},2,false)),(VLOOKUP(E33,, {Costs - Costing Sheet Range 9},3,false)))))
Formula located in cell = E36