ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   IF OR AND in same conditional formula (https://www.excelbanter.com/excel-worksheet-functions/264696-if-same-conditional-formula.html)

Ron

IF OR AND in same conditional formula
 
I'm setting up a conditional formula to use in a conditional format, where
depending on a couple of different conditions, the cell with the date entered
will be color-coded either red, yellow or green.

In this particular formula, I'm using the following variables:
- cell C7 = a percentage (70%)
- cell CI7 = the number of days calculated from today (19)

I've constructed the formula as such (makes sense to me, but Excel doesn't
like it)
=IF(AND(CI7<=30,D7=70%),(OR(AND(CI7=90,D7<=50%)) )).

Essentially, I'm asking Excel to evaluate two conditions, either of which
would have the conditional format set the cell color to green.

Tried it also as two nested IF statements, but that doesn't work either. A
single IF statement, with no values entered for TRUE or FALSE works fine... I
just want to simplify my conditional formatting formulae by including any
condition that meets my criteria for color coding...

Any ideas??

ExcelBanter AI

Answer: IF OR AND in same conditional formula
 
It looks like there are a few issues with the formula you've provided. Here's a breakdown of what's going wrong:
  1. The syntax for the AND function is incorrect. You need to separate each condition with a comma, not a space. So it should be
    Code:

    AND(CI7<=30,D7=70%)
    .
  2. The syntax for the OR function is also incorrect. You need to provide two separate conditions for it to evaluate. So it should be
    Code:

    OR(AND(CI7=90,D7<=50%),[second condition])
    .
  3. You haven't provided a value for the TRUE condition of the IF statement. This is necessary for the formula to work.

Here's a revised formula that should work for you:

Code:

=IF(AND(CI7<=30,D7=70%),"Green",IF(AND(CI7=90,D7<=50%),"Green",""))
This formula first checks if both conditions are met (CI7 is less than or equal to 30 and D7 is greater than or equal to 70%). If they are, it returns "Green". If not, it moves on to the next IF statement, which checks if the second set of conditions are met (CI7 is greater than or equal to 90 and D7 is less than or equal to 50%). If they are, it returns "Green". If neither set of conditions is met, it returns an empty string (""), which means no formatting will be applied.

Tom-S[_2_]

IF OR AND in same conditional formula
 
Try this:

=IF(OR(AND(C17<=30,D7=70%),AND(C17=90,D7<=50%)), if true statement here,
if false statement here)

If you don't want to use an IF statement overall, try just the OR statement
within the conditional formatting feature (under the Format menu).

"Ron" wrote:

I'm setting up a conditional formula to use in a conditional format, where
depending on a couple of different conditions, the cell with the date entered
will be color-coded either red, yellow or green.

In this particular formula, I'm using the following variables:
- cell C7 = a percentage (70%)
- cell CI7 = the number of days calculated from today (19)

I've constructed the formula as such (makes sense to me, but Excel doesn't
like it)
=IF(AND(CI7<=30,D7=70%),(OR(AND(CI7=90,D7<=50%)) )).

Essentially, I'm asking Excel to evaluate two conditions, either of which
would have the conditional format set the cell color to green.

Tried it also as two nested IF statements, but that doesn't work either. A
single IF statement, with no values entered for TRUE or FALSE works fine... I
just want to simplify my conditional formatting formulae by including any
condition that meets my criteria for color coding...

Any ideas??


Ron

IF OR AND in same conditional formula
 
Thanks Tom! Worked like a charm!!

"Tom-S" wrote:

Try this:

=IF(OR(AND(C17<=30,D7=70%),AND(C17=90,D7<=50%)), if true statement here,
if false statement here)

If you don't want to use an IF statement overall, try just the OR statement
within the conditional formatting feature (under the Format menu).

"Ron" wrote:

I'm setting up a conditional formula to use in a conditional format, where
depending on a couple of different conditions, the cell with the date entered
will be color-coded either red, yellow or green.

In this particular formula, I'm using the following variables:
- cell C7 = a percentage (70%)
- cell CI7 = the number of days calculated from today (19)

I've constructed the formula as such (makes sense to me, but Excel doesn't
like it)
=IF(AND(CI7<=30,D7=70%),(OR(AND(CI7=90,D7<=50%)) )).

Essentially, I'm asking Excel to evaluate two conditions, either of which
would have the conditional format set the cell color to green.

Tried it also as two nested IF statements, but that doesn't work either. A
single IF statement, with no values entered for TRUE or FALSE works fine... I
just want to simplify my conditional formatting formulae by including any
condition that meets my criteria for color coding...

Any ideas??



All times are GMT +1. The time now is 11:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com