F
Frank Kabel
...
Hi Harlan
thanks for this. Thought I'd tested it but only with real blanks. So
thanks for the correction.
But this formula definetely won't help if K2 contains for example ="".
It will also return an error. Of course not on the condition part but
on the TRUE part of the If statement
This is a nice one (though it will not return "" in case of J2:K2 are
blank -> which seems to be the OP's desired result).
So to add an alternative I'd use:
=IF(AND(N(J2),N(K2)),K2-J2,"")
Frank
Always better to look for causes then to try trial & error treating the
symptoms. If K2-J2 returns an error, then what does that imply are the
contents of K2 or J2 or both? Either one or the other or both are text or
error values themselves. If K2 were ="" or anything returning the same
value, =IF(K2,1,0) would return a #VALUE! error (try it!). For that matter,
if K2 were either ="1" or ="0" or equivalents, the previous IF formula would
still return #VALUE! (try it!). AND(K2,AnythingElseYouCouldThinkOf) would
also return a #VALUE! error. Excel just doesn't like text, even numeric
text, in boolean contexts.
Hi Harlan
thanks for this. Thought I'd tested it but only with real blanks. So
thanks for the correction.
If the OP's formula above is returning errors, then the formula the OP needs
is either
=IF(COUNTIF($J2:$K2,"<>0")=2,$K2-$J2,"")
But this formula definetely won't help if K2 contains for example ="".
It will also return an error. Of course not on the condition part but
on the TRUE part of the If statement
=SUMPRODUCT(J2:K2,{-1,1})
This is a nice one (though it will not return "" in case of J2:K2 are
blank -> which seems to be the OP's desired result).
So to add an alternative I'd use:
=IF(AND(N(J2),N(K2)),K2-J2,"")
Frank