Professional Documents
Culture Documents
If This and That or Logical
If This and That or Logical
Generic formula
=IF(AND(A1="x",OR(B1="y",B1="z")),"x","")
Explanation
To test for various combinations of this AND that, or this OR that, you can use the
IF function with the AND and OR functions. In the example shown, the formula in
D6 is:
=IF(AND(B6="red",OR(C6="small",C6="medium")),"x","")
When an item is "red", and either "small" or "medium", the formula returns "x".
All other combinations return an empty string ("").
This snippet will return TRUE only if the value in B6 is "red" AND the value in
C6 is either "small" or "medium". It is placed inside the IF function as the logical
test. When the logical test returns TRUE, the IF function returns "x". When the
logical test returns FALSE, the IF function returns an empty string ("").