Forum Discussion
RobertsTrying
Jun 18, 2024Copper Contributor
Excel challenge calculating when a formula leaves a blank cell
Wondering if anyone can make this formula work? I just want to subtract 2 numbers but there are formulas in the reference and resulting cells. The following formula results in a blank answer when the...
- Jun 18, 2024
SergeiBaklan
Jun 18, 2024Diamond Contributor
- RobertsTryingJun 18, 2024Copper ContributorThanks for trying but if one of the cells (p or q) is blank, your formula gives me a #Value! error
because there is a formula in both cells.- SergeiBaklanJun 18, 2024Diamond Contributor
I see. So actually you could have empty strings in the cells. Formula can't return blank as value. WE may use
=IF( (P10="")*(Q10=""), "", N(P10)-N(Q10) )N() applied to any text (includes empty string) returns zero.
- RobertsTryingJun 18, 2024Copper ContributorI learned something new with the N() function. Thanks again Sergei. This is very helpful now and for future reference.
- RobertsTryingJun 18, 2024Copper ContributorI figured it out with Bing AI. This formula works in all conditions:
=IF(AND(ISNUMBER(P10), ISNUMBER(Q10)), P10 - Q10, IF(OR(ISFORMULA(P10), ISFORMULA(Q10)), IF(ISNUMBER(P10), P10, IF(ISNUMBER(Q10), -Q10, "")), ""))- SergeiBaklanJun 18, 2024Diamond Contributor
IMHO, AI overcomplicated it