Field Guide

AND, OR, and NOT in Excel: the logical functions and how they slot into an IF

Updated

AND, OR, and NOT are Excel’s logical functions, and each one returns TRUE or FALSE. AND(logical1, [logical2], ...) is TRUE only when every condition is TRUE; OR(logical1, [logical2], ...) is TRUE when at least one condition is; and NOT(logical) flips a single result, turning TRUE into FALSE and FALSE into TRUE. On their own they just report TRUE or FALSE, so the usual move is to drop one into an IF as the logical test, the first argument that decides which branch runs: =IF(AND(B2>=90, C2>=90), "Pass", "Review") marks a row Pass only when both scores reach 90.

How IF itself works, how to nest several IFs, and when the flatter IFS reads more cleanly all live in the IF function guide. Here the IF is only the wrapper that turns the TRUE or FALSE from AND, OR, or NOT into the result you actually want.

What do AND, OR, and NOT do on their own?

Each function takes conditions and boils them down to a single TRUE or FALSE.

Each condition is normally a comparison built from an operator such as >, <, >=, or <>; the whole set of them is in formula symbols. The arguments do have to resolve to logical values. Point AND or OR at a range that holds no TRUE or FALSE values and you get a #VALUE! error, though text and blank cells sitting inside a referenced range are skipped rather than counted.

A related use: these three also work as the formula behind a conditional formatting rule, where you drop the IF and let AND, OR, or NOT decide on its own whether a cell gets formatted.

How do I put AND inside an IF?

The AND function goes in IF’s first slot, the logical test. IF then returns its true branch only when AND comes back TRUE. Here two exam scores decide a Pass or a Review, and both scores have to clear the bar:

D2
fx
=IF(AND(B2>=90, C2>=90), "Pass", "Review")
A B C D
1 Name Written Practical Result
2 Ada 95 92 Pass
3 Bo 88 96 Review
4 Cy 90 90 Pass
Both scores must reach 90 for a Pass. Ada has 95 and 92, so AND is TRUE and D2 reads Pass. Bo scored 88 on the written test, so AND is FALSE and the row reads Review. Cy sits exactly on 90 in both, and because the test uses >= rather than >, that still passes.

Read the formula from the inside out. AND(B2>=90, C2>=90) resolves to TRUE or FALSE first, and only then does IF pick a branch from it. Notice the closing parenthesis right after the two conditions: the AND ends there, and "Pass" and "Review" are IF’s second and third arguments, not part of the AND. That layout is the same whichever of the three functions you use.

AND and OR both accept up to 255 conditions, but stacking more than a handful makes a formula hard to build, test, and maintain, so keep the list short.

How do OR and NOT fit the same slot?

OR sits in exactly the same position as AND. The only thing that changes is what makes it TRUE: any single condition passing is enough. This flags a row for Merit when either score reaches 90:

D2
fx
=IF(OR(B2>=90, C2>=90), "Merit", "None")

Swap OR for AND in that formula and the meaning inverts from “either score” to “both scores”, with nothing else touched.

NOT is the odd one of the three, because it takes a single condition and hands back its opposite. On its own it looks like this:

fx
=NOT(A2>100)

That returns FALSE when A2 is greater than 100 and TRUE otherwise. Wrap it in an IF the same way as the others when you want to act on the reversed result. NOT earns its keep for “is not this” tests: NOT(B2="Closed") is TRUE for every status that is not Closed, which is often easier to read than spelling out each of the other values.

Why can’t I write AND between two comparisons?

This is the mistake that trips people who know the logic but not the syntax. In plain English you would say “greater than 1 and less than 10”, so it is tempting to type the word AND straight into the formula. Excel does not read it that way:

=IF(A2>1 AND A2<10, "Yes", "No")
Excel has no plain AND operator to sit between two comparisons, so it will not accept this. AND is a function: wrap the conditions inside it, as =IF(AND(A2>1, A2<10), "Yes", "No").

The fix is to make AND do the joining. Put both comparisons inside the function, separated by a comma, and the function returns the one TRUE or FALSE that IF needs. The same holds for OR: it is OR(A2>1, A2<10), never A2>1 OR A2<10.

The short version

Frequently asked questions

What does the AND function do in Excel?
AND returns TRUE only when all of its conditions are TRUE, and FALSE the moment one of them is FALSE. Its syntax is AND(logical1, [logical2], ...), and it accepts up to 255 conditions separated by commas. For example, =AND(A2>1, A2<100) is TRUE only when A2 is both above 1 and below 100.
How do I combine IF with AND in Excel?
Put the AND function where IF's first argument, the logical test, goes: =IF(AND(B2>=90, C2>=90), then one result, otherwise another). AND is TRUE only when every condition inside it holds, so IF returns the true branch only when both scores reach 90, and the false branch otherwise. You cannot place the word AND between the two comparisons; it has to be wrapped in the AND function.
What is the difference between AND and OR in Excel?
AND needs every condition to be TRUE before it returns TRUE, while OR needs only one. So =AND(A2>0, A2<100) is TRUE only inside that range, and =OR(A2<0, A2>100) is TRUE only outside it. Both functions accept up to 255 conditions; the difference is whether all of them or just one has to pass.
What does the NOT function do in Excel?
NOT reverses a logical value: it turns TRUE into FALSE and FALSE into TRUE. Its syntax is NOT(logical), and unlike AND and OR it takes exactly one condition. For example, =NOT(A2>100) is TRUE whenever A2 is not greater than 100, and FALSE when it is.
Why does my AND formula return a #VALUE! error?
AND and OR evaluate logical conditions, so pointing one at a range that holds no TRUE or FALSE values at all returns the #VALUE! error. Text and empty cells inside a referenced range are ignored rather than causing the error, but a range with nothing logical in it cannot be evaluated. Make sure each argument is a comparison or a cell that resolves to TRUE or FALSE.
Can I write A2>1 AND A2<10 in an Excel formula?
No. AND is a function, not an operator, so you cannot place the word AND between two comparisons the way you would in a sentence. Write the conditions inside the function as AND(A2>1, A2<10), and to act on the result put it in an IF: =IF(AND(A2>1, A2<10), then one result, otherwise another).

Catch the errors before they ship

Reviewing a change to a model? Compare the two versions in your browser and see every changed cell, formula, and value. It's free, and nothing leaves your computer.