Error in Excel formula referencing its own cell in Numbers app

I REQUIRE A FORMULA FOR THE FOLLOWING

IF E25 IS LESS THAN C37 THEN E37 - IF E25 IS GREATER THAN B38 AND LESS THAN C38 THEN E25 MINUS C37 MULTIPLIED BY E38 - IF E25 IS GREATER THAN B39 AND LESS THAN C39 THEN E25 MINUS C38 MULTIPLIED BY E39 PLUS D39 - IF E25 IS GREATER THAN B40 AND LESS THAN C40 THEN E25 MINUS C39 MULTIPLIED BY E40 PLUS D40 - IF E25 IS GREATER THAN B41 THEN E25 MINUS C40 MULTIPLIED BY E41 PLUS D40


I TRIED

=IF(E25<C37,E37,IF(AND(E25>B38,E25<C38),(E25-C37)*E38,IF(AND(E25>B39,E25<C39),(E25-C38)*E39+D39,IF(AND(E25>B40,E25<C40),(E25-C39)*E40+D40,IF(E25>B41,(E25-C40)*E41+D40,”")))))

BUT I GET ERROR MESSAGE This formula can’t reference its own cell or depend on another formula that references this cell.


ANY HELP APPRECIATED


EVAN


[Re-Titled by Moderator]

Original Title: FORMULA NEEDED


Posted on Jun 20, 2025 7:59 PM

Reply
4 replies

Jun 21, 2025 2:30 AM in response to ZIKUNJA

You haven't said what cell you want the formula in. It can't be E25 because the formula refers to E25.


When you end up with long nested formulas like this it is easy to get twisted up in the logic. Usually that's a sign you should consider a different approach.


It seems as if you have a series of upper and lower limits and you want to return a value depending on where the value in E25 falls within these. You might consider constructing a look-up table and using XLOOKUP to retrieve a value.


If want to stick with the multiple conditionals approach then don't use IF. Use the modern IFS function, something like this:


=IFS(E25<C37,E37,
AND(E25>B38,E25<C38),(E25−C37)*E38,
AND(E25>B39,E25<C39),(E25−C38)*E39+D39,
AND(E25>B40,E25<C40),(E25−C39)*E40+D40,
E25 >B41,(E25−C40)*E41+D40)



IFS - Apple Support


XLOOKUP - Apple Support



A screenshot would help provide further suggestions.


SG





Jun 21, 2025 10:45 AM in response to ZIKUNJA

I agree with SGIII here - IFS() is your friend. You can set multiple conditions and the first one that matches is the one that gets returned. Your formula also cannot refer to itself in any way, so this has to be outside of the range of cells you're referencing (otherwise changing the value of the cell would cause a recursive loop where it would have to recalculate the formula, which would change one of the cells in it, which would cause it to recalculate again... ad infinitum).


That said, this formula seems to achieve what you describe:



=IFS(E25<C37,E37,
 AND(E25>B38,E25<C38),E25−C37×E38,
 AND(E25>B39,E25<C39),E25−C38×E39+D39,
 AND(E25>B40,E25<C40),E25−C39×E40+D40,
 E25>B41,E25−C40×E41+D40)


although you might want to validate the order of operations... "THEN E25 MINUS C38 MULTIPLIED BY E39 PLUS D39" could be interpreted as:


E25 - (C38 x E39) + D39 (default based on order of operations rules)

or

((E25 - C38) x C39) + D39

or

(E25 - C38) x (C39 + D39)

or

E25 - (C38 x (C39 + D39))


plus many other permutations that I can't even wrap my head around :)

Jun 21, 2025 11:15 AM in response to ZIKUNJA

One thing not addressed is what to do if none of your conditions are met. With the IF formula, if none of your conditions are met and you don't specify what to do you will get the default result of FALSE. With IFS if none of the conditions are met you end up with an error triangle because it has to have at least condition that is true. You can add one additional condition and result to the IFS so you don't get an error triangle.


=IFS(.......,TRUE, "")

or

=IFS(.......,TRUE, 0)

or whatever you want the result to be


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Error in Excel formula referencing its own cell in Numbers app

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.