 SOLVED

# If formula

Good evening

Fundamental question:

I am trying to make a stock sheet, and I cannot get the IF formula to pick up the second part - the error message is "You have used too many arguments". If someone would kindly assist, I will be ever so grateful

IF(AND(D4>0,E4>0),(c4-d4), c4),(c4+e4),c4). 4 Replies

# Re: If formula

@Hanna1701.... You need to explain your intended logic.  And it would be best to attach an Excel file that demonstrates the problem.  I cannot read your image.

The form of an IF expression is:

IF(condition, value_if_true, value_if_false)

So the first part of your formula is a complete IF expression, to wit (removing unnecessary parentheses):

IF(AND(D4>0,E4>0), c4-d4, c4)

That says.... If D4>0 and E4>0, return C4-D4; otherwise, return C4.

Given that, it is unclear what your intent is for the rest of the formula, which is badly formed, to wit (removing last parenthesis, which is incorrect syntax):

=IF_expression, c4+e4, c4

We cannot put 3 expressions, comma-separated, into a formula.  And I'm sure that is not your intention.

Perhaps you meant to write a nested IF expression, with another condition (TBD).  The intended form might be:

IF(AND(D4>0,E4>0), c4-d4, IF(condition, c4+e4, c4))

That says....  If D4>0 and E4>0, return C4-D4.  Otherwise, if "condition" is true, return C4+E4; otherwise, return C4.

So C4 is returned if both "D4>0 and E4>0" is false (i.e. D4<=0 or E4<=0 or both) and "condition" is false.

# Re: If formula

Thank you - you made it so much clearer

best response confirmed by allyreckerman (Microsoft)
Solution

# Re: If formula

@Hanna1701.... I'm glad that helped.  But I think you should explain the logic that you want in English and show us the formula that you think works for you.

It just occurred to me that perhaps the formula that you (should) want is:

=IF(D4>0, C4-D4, IF(E4>0, C4+E4, C4))

# Re: If formula

Thank you so much - got it working with your guidance.