user3878505
user3878505

Reputation: 11

Why does this Excel IF statement have "too many arguments"?

Why does this Excel statement have "too many arguments"? Excel allows up to 7 nested IFs and I can't see the error with commas or parentheses?

=IF(C7>$B$1,(IF B7=C7, “COMPLETE”, “AT RISK”), IF(C7<=B7, IF((C7-$B$1)<14,IF(C7>B7, “AT RISK”,”CHECK”), “ON TRACK”), "ON TRACK")

I've tried tabbing it like regular code and am struggling to find the error. Can anyone help?

If CPS(C7) > Today(B1)
  TRUE If CPS(C7) = Due(B7)
    TRUE return COMPLETE
    FALSE return AT RISK
  FALSE If CPS(C7)>Today(B1)
    TRUE If CPS within 2 weeks
      TRUE IF CPS(C7) > Due(B7)
        TRUE return AT RISK
        FALSE return Check
      FALSE return ON TRACK
  FALSE return ON TRACK

Thanks!

Upvotes: 0

Views: 731

Answers (1)

Tmdean
Tmdean

Reputation: 9299

You should try indenting the actual code instead of writing pseudocode and indenting that.

=IF(C7>$B$1,
    (IF B7=C7, "COMPLETE", "AT RISK"),
    IF(C7<=B7,
        IF((C7-$B$1)<14,
            IF(C7>B7, "AT RISK", "CHECK"),
            "ON TRACK"),
        "ON TRACK")

When you look at it like this, it should become obvious that you're missing a right paren at the end of the statement and the left paren on the second line is misplaced.

=IF(C7>$B$1,
    IF(B7=C7, "COMPLETE", "AT RISK"),
    IF(C7<=B7,
        IF((C7-$B$1)<14,
            IF(C7>B7, "AT RISK", "CHECK"),
            "ON TRACK"),
        "ON TRACK"))

I should also mention that this logic is getting convoluted for a single Excel formula. You should break it into multiple formulas or move to another platform if your worksheet really requires this level of complexity. Complicated Excel spreadsheets are notorious for being full of errors.

Upvotes: 2

Related Questions