Depending what word is in a cell i want to do a calculation

I’m trying to do a calculation based on the contents of another cell - if a cell says SHORT I want to perform a calculation. If a cell says LONG I want to perform a different calculation - Basically 2 different calculations based on what word is in a certain cell. Probably easy to do but I’m not a Numbers whizz!


Any help appreciated


regards


c

Posted on Jul 11, 2024 1:25 PM

Reply
Question marked as Top-ranking reply

Posted on Jul 11, 2024 1:42 PM

This is pretty straightforward, using an 'IF' formula.


IF performs a check and returns one of two values, depending on whether the check returns TRUE or FALSE.


=IF(<condition>,<value if true>,<value if false>)


For example, to check if cell A2 contains the value "SHORT", you'd write:


=IF(A2="SHORT",A3*B3,A3/B3)


In this case, if A2 = "SHORT", it returns the value of A3 * B3, otherwise if returns A3 / B3


Note that isn't 100% what you asked, since it would return 'A3/B3/ any time the cell does not contain "SHORT" (including an empty cell), whereas you specifically stated 'a cell says LONG. To achieve that, add the 'IF="LONG"' to the <false> condition:


=IF(A2="SHORT",A3*B3,IF(A2="LONG",A3/B3,0))


Now, if A2 contains "SHORT" the formula returns A3*B3, otherwise it then checks IF A3 = "LONG" - if this second check returns true the formula returns A3/B3, otherwise it returns 0

4 replies
Question marked as Top-ranking reply

Jul 11, 2024 1:42 PM in response to CitizenEra5ed

This is pretty straightforward, using an 'IF' formula.


IF performs a check and returns one of two values, depending on whether the check returns TRUE or FALSE.


=IF(<condition>,<value if true>,<value if false>)


For example, to check if cell A2 contains the value "SHORT", you'd write:


=IF(A2="SHORT",A3*B3,A3/B3)


In this case, if A2 = "SHORT", it returns the value of A3 * B3, otherwise if returns A3 / B3


Note that isn't 100% what you asked, since it would return 'A3/B3/ any time the cell does not contain "SHORT" (including an empty cell), whereas you specifically stated 'a cell says LONG. To achieve that, add the 'IF="LONG"' to the <false> condition:


=IF(A2="SHORT",A3*B3,IF(A2="LONG",A3/B3,0))


Now, if A2 contains "SHORT" the formula returns A3*B3, otherwise it then checks IF A3 = "LONG" - if this second check returns true the formula returns A3/B3, otherwise it returns 0

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.

Depending what word is in a cell i want to do a calculation

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