Home » excel » Excel stuck on IF AND OR

# Excel stuck on IF AND OR

Questions:

I’ve been trying to figure this out for about an hour, but just can’t understand how it works despite researching how to use the IF AND OR on Google.

Basically what I am trying to figure out is how to display this:

If the value in E4 is larger than \$A\$5 AND equal to or larger than \$A\$9 THEN E4/C3*100 BUT if E4 is larger than \$A\$5 AND smaller than \$A\$9 THEN E4/C3*100 WITH a MINUS (-) symbol in front of the displayed result.

I’m still learning how to use Excel, so this is a bit advanced for me. Could somebody explain this please?

``````=IF(AND(E4>\$A\$5,E4>=\$A\$9),
E4/C3*100,
IF(AND(E4>\$A\$5,E4<\$A\$9),
E4/C3*100))
``````

This `IF()` statement follows the exact logic you described in your question.

As you are looking for the same result for either scenarios though I would approach this with a single `IF()`:

`IF(AND(E4>\$A\$5,OR(E4>=\$A\$9,E4<\$A\$9)),E4/C3*100)` – as both results just want E4 to be >\$A\$5 we don’t need to list this argument twice

But now we can see that the second argument will always be true, so you are in fact only looking for:

`IF(E4>\$A\$5,E4/C3*100)`

AND takes a number of conditions and returns TRUE if all the conditions equate to TRUE.

You have two `AND` statements in your formula:

If the value in E4 is larger than \$A\$5 AND equal to or larger than \$A\$9

This is written as `AND(\$E\$4>\$A\$5,\$E\$4>=\$A\$9)` and will return TRUE or FALSE.

Your second `AND` statement is:

if E4 is larger than \$A\$5 AND smaller than \$A\$9

This is written as `AND(\$E\$4>\$A\$5,\$E\$4<\$A\$9)` and will return TRUE or FALSE.

The IF function will return one of two answers based on a comparison returning TRUE or FALSE (such as the `AND` statements).

So the `IF` function is built as `=IF(Comparison, Result if TRUE, Result if FALSE)`.

Your comparison needs two `IF` functions so that FALSE is returned if E4 is smaller than A5.

`=IF(Comparison_1, Result if TRUE, IF(Comparison_2, Result if TRUE, Result if FALSE))`

Using your conditions this will be written as (replace the last FALSE with what you want to happen if no conditions are met):

``````=IF(AND(\$E\$4>\$A\$5,\$E\$4>=\$A\$9),\$E\$4/\$C\$3*100,IF(AND(\$E\$4>\$A\$5,\$E\$4<\$A\$9),\$E\$4/\$C\$3*100, FALSE))
``````

``````=IF(AND(E4>\$A\$5,E4>=A9),E4/C3*100,IF(AND(E4>\$A\$5,E4<\$A\$9),-E4/C3*100,"HELP"))