Share via

This formula keeps crashing my excel: =IF(D3<G3,O,IF(G3>D3,SUM,D3-G3))

Carla C 20 Reputation points
2025-07-18T23:04:27.55+00:00

User's image

User's image

=IF(D3<G3,O,IF(G3>D3,SUM,D3-G3))

When I try to insert or delete a row the program crashes.

It either just closes or I get a message that there isn't enough resources.

We have managed to narrow it down to the formula but can't figure out why it keeps crashing the sheet...

I had some bad ram but it was replaced and still the problem exists.

I've done all the trouble shooting I can think of and that was suggested and nothing is fixing the problem. Seem like a pretty straight forward formula.

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments

Answer accepted by question author

  1. Huy-K 11,590 Reputation points Microsoft External Staff Moderator
    2025-07-18T23:40:42.5933333+00:00

    Dear Carla C,

    Good day! Thank you for posting your question in the Microsoft Q&A forum.

    We apologize for any inconvenience you may encounter when using our services/ products. Based on your description, some of the issues in your formulation of this equation include the following:

    Undefined Variables:

    O and SUM are not valid Excel functions or defined names unless you've created named ranges or variables with those names. If not, Excel will throw an error.

    Incorrect Use of SUM:

    SUM is a function and needs arguments like SUM(A1:A10). Using SUM alone without parentheses or arguments will cause Excel to misinterpret it.

    Redundant Logic:

    The formula checks both D3<G3 and G3>D3, which are logically the same. This redundancy might not crash Excel, but it’s inefficient.

    Kindly try these following steps:

    If your goal is to:

    • Return a value O when D3 < G3
    • Return the sum of something when G3 > D3
    • Otherwise return D3 - G3

    Then a corrected version might look like:

    =IF(D3<G3,"O",IF(G3>D3,SUM(D3,G3),D3-G3))

    Or if "O" is just a placeholder and you want to return 0:

    =IF(D3<G3,0,IF(G3>D3,SUM(D3,G3),D3-G3))

    Tips:

    Check for circular references: If this formula is part of a loop or references itself indirectly, it could cause crashes.

    Named ranges: Make sure O and SUM aren’t accidentally defined as named ranges pointing to large or invalid areas.

    Excel version: Some older versions of Excel may behave unpredictably with malformed formulas.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    User's image

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Dana 10 Reputation points
    2025-07-20T12:31:07.4333333+00:00

    I would use:

    =MAX( D3-G3, 0 )

    0 comments No comments

  2. Ashish Mathur 101.8K Reputation points Volunteer Moderator
    2025-07-19T00:02:43.98+00:00

    Hi,

    Does this work?

    =IF(D3<G3,0,D3-G3)

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.