like this?

=IFERROR(IF(($E5<>$E4),IF($E5<>"",$Y5,($Y5+$Y4)),""),"")
well, technically that returns an empty text string rather than a blank cell.