How do I put logical operators in an Excel =IF Formula?
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.
Solution 1:
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")