I don't think so you need to go for UDF.

Non Array Approach
Formula: copy to clipboard
=IF(B2<0,"",A2/SUMPRODUCT(--($B$2:$B$4>0),$A$2:$A$4))