Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to enter a formula to display text according to an IF condition. The best I can manage is something like...

=IF(myval>=minval & myval <= maxval, "OK", "Not OK")

But this appears to work exactly wrongly, displaying OK when myval is out of range and Not OK when it is in range. How do I specify the logical AND correctly? I have tried && as I have seen in questions here, and inner brackets, but these result in errors.

share|improve this question
up vote 30 down vote accepted

The logical operations are represented by formulae:

 AND( condition1 , condition2 , ... )

 OR( condition1 , condition2 , ... )

 NOT( condition )

Each condition can be pretty much anything with a logical evaluation, meaning you can nest logical operations by nesting the formulae as required.

So in your case you need:

 =IF( AND( myval>=minval , myval <= maxval ), "OK", "Not OK")
share|improve this answer
    
Thank you. – Brian Hooper Jan 7 '11 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .