# Logical Functions in Excel: AND, OR, XOR and NOT
> Learn the Excel logical functions AND, OR, XOR and NOT with real tests, the operator shortcuts for OR, and how to combine them inside IF.

- Web page: https://logicexcel.com/functions/logical-functions
- Language: en
- Also in: [Deutsch](https://logicexcel.com/de/functions/logical-functions.md), [Español](https://logicexcel.com/es/functions/logical-functions.md)
- Updated: 2026-11-03
- Practice this in the browser: https://logicexcel.com/practice/17

Excel has four logical functions, and each one answers a TRUE or FALSE question. `=AND(B2>=3,C2>=70)` is TRUE only when both tests pass. `=OR(C2>=90,B2>=8)` is TRUE when at least one passes. `=NOT(D2="Yes")` flips the answer. `=XOR(E2="Yes",F2="Yes")` is TRUE when exactly one of two tests passes.

This guide shows each function with real tests, the symbol shortcuts for OR, the errors, and how to put them inside IF.

## TL;DR

- AND needs every test to pass, OR needs at least one, NOT reverses one test, and XOR is TRUE when an odd number of tests pass.
- With two tests, XOR means "one or the other, but not both." With three or more, it means "an odd number are true."
- On their own, these functions return TRUE or FALSE. Put them in the first slot of IF to return words or numbers.
- Excel has no `&&` or `||`. Use the functions, or multiply for AND and add for OR.
- Never write a "between" test as `3<B2<10`. Excel reads it as `(3<B2)<10` and gives the wrong answer. Use `AND(B2>3,B2<10)`.
- AND, OR and NOT work in every version of Excel. XOR needs Excel 2013 or later.

## Table of Contents

- [Sample data for the logical function examples](#sample-data-for-the-logical-function-examples)
- [Logical functions syntax](#logical-functions-syntax)
- [AND function: every test must pass](#and-function-every-test-must-pass)
- [OR function: at least one test passes](#or-function-at-least-one-test-passes)
- [NOT function: reverse a result](#not-function-reverse-a-result)
- [XOR function: exactly one test passes](#xor-function-exactly-one-test-passes)
- [Combine AND, OR and NOT in one formula](#combine-and-or-and-not-in-one-formula)
- [Logical functions inside IF](#logical-functions-inside-if)
- [Excel symbol for OR and AND](#excel-symbol-for-or-and-and)
- [Logical functions compared with their alternatives](#logical-functions-compared-with-their-alternatives)
- [Versions and other languages](#versions-and-other-languages)
- [Logical function errors and how to fix them](#logical-function-errors-and-how-to-fix-them)
- [What learners get wrong](#what-learners-get-wrong)
- [A worked job: the hiring shortlist](#a-worked-job-the-hiring-shortlist)
- [Practice the logical functions](#practice-the-logical-functions)
- [FAQ](#faq)
- [Sources](#sources)

## Sample data for the logical function examples

The examples use a hiring sheet for seven candidates. Row 1 holds the headings and the candidates sit in rows 2 to 8. Column B is years of experience, column C is a test score out of 100, column D says whether the candidate holds the certificate, and columns E and F say whether the candidate came through a referral or an agency.

| Row | A: Name | B: Years | C: Score | D: Certified | E: Referral | F: Agency |
|---|---|---|---|---|---|---|
| 1 | Name | Years | Score | Certified | Referral | Agency |
| 2 | Amara | 5 | 82 | Yes | Yes | No |
| 3 | Boris | 1 | 91 | No | No | No |
| 4 | Chipo | 3 | 64 | Yes | No | Yes |
| 5 | Dmitri | 8 | 58 | Yes | Yes | Yes |
| 6 | Esi | 2 | 77 | No | No | Yes |
| 7 | Farid | 6 | 70 | Yes | No | No |
| 8 | Grace | 0 | 95 | No | Yes | No |

Type each formula in an empty cell next to row 2 and fill it down to row 8.

## Logical functions syntax

- `=AND(logical1, [logical2], ...)`
- `=OR(logical1, [logical2], ...)`
- `=XOR(logical1, [logical2], ...)`
- `=NOT(logical)`

| Argument | Required | What it does |
|---|---|---|
| logical1 | Yes | A test that gives TRUE or FALSE, such as `B2>=3`, or a cell or range that holds TRUE and FALSE values. |
| logical2, ... | No | More tests, up to 255 in total for AND, OR and XOR. |
| logical (NOT only) | Yes | The single test to reverse. NOT takes exactly one argument. |

Here is the short version of when each one returns TRUE:

| Function | Returns TRUE when | Returns FALSE when |
|---|---|---|
| AND | Every test is TRUE | Any test is FALSE |
| OR | At least one test is TRUE | Every test is FALSE |
| XOR | An odd number of tests are TRUE | An even number, including none, are TRUE |
| NOT | The test is FALSE | The test is TRUE |

For the comparison symbols that go inside the tests, see our guide to [logical operators in Excel](https://logicexcel.com/functions/logical-operators).

## AND function: every test must pass

AND is the strict one. Use it when a row has to clear several bars at once. Suppose a candidate needs at least 3 years of experience and a score of 70 or more:

`=AND(B2>=3,C2>=70)`

Amara has 5 years and a score of 82, so both tests pass and the result is TRUE. Boris has a 91 but only 1 year, so the first test fails and the result is FALSE. Chipo has 3 years but a score of 64, so the second test fails. Farid has 6 years and exactly 70, and `>=` includes 70, so he gets TRUE. Across rows 2 to 8 the results are TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE.

Excel checks every test in the list. It does not stop at the first FALSE the way some programming languages do. That matters if one of your tests could produce an error, because the error then spreads to the whole AND.

AND also accepts a range. To check that every score in the sheet is at least 50:

`=AND(C2:C8>=50)`

The lowest score is 58, so the answer is TRUE. In Microsoft 365 this works as typed. In Excel 2019 and earlier, finish it with Ctrl+Shift+Enter, because the comparison inside AND is an array.

Numbers count as tests too. A zero is FALSE and any other number is TRUE:

`=AND(B2,C2)`

Amara's 5 and 82 are both nonzero, so the result is TRUE. Grace has 0 years, so `=AND(B8,C8)` is FALSE. This is handy for quick checks, but it hides the intent, so write the comparison out when someone else will read the sheet.

## OR function: at least one test passes

OR is the forgiving one. It asks whether any condition is met. A candidate goes on the fast track when the score is 90 or more, or when the candidate has 8 or more years:

`=OR(C2>=90,B2>=8)`

Amara fails both tests, so the result is FALSE. Boris has a 91, so the result is TRUE. Dmitri has 8 years, which is enough, so TRUE. Grace scores 95, so TRUE. The results for rows 2 to 8 are FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE.

To check whether a cell equals one of several words, write one test for each word:

`=OR(E2="Yes",F2="Yes")`

Amara has a Yes in the referral column, so the result is TRUE. Boris has two No answers, so FALSE. Excel ignores capitals in the comparison, so `"yes"` matches too.

OR can also read a row or column directly, so you do not have to type each cell:

`=OR(E2:F2="Yes")`

That returns TRUE for Amara, because at least one of the two cells holds Yes. Like AND, it is an array formula behind the scenes, so older versions of Excel need Ctrl+Shift+Enter.

## NOT function: reverse a result

NOT turns TRUE into FALSE and FALSE into TRUE. It takes one test only:

`=NOT(D2="Yes")`

Amara is certified, so `D2="Yes"` is TRUE and NOT makes it FALSE. Boris is not certified, so the result is TRUE. NOT earns its place when the test inside is long, and you want the reader to see the intention first. For a plain not-equal check, the `<>` operator is shorter:

`=D2<>"Yes"`

It gives the same answers on every row. Reach for NOT when you wrap something larger, such as `NOT(AND(...))` or `NOT(ISBLANK(...))`.

The "and not" pattern comes up often: pass one test but fail another. Candidates who have the certificate and did not come through an agency:

`=AND(D2="Yes",NOT(F2="Yes"))`

Amara gives TRUE. Chipo is certified but came through an agency, so the NOT part is FALSE and the result is FALSE. Farid gives TRUE.

## XOR function: exactly one test passes

XOR stands for exclusive or. It is the least-used function in the family and the one that surprises people. With two tests, XOR is TRUE when exactly one of them is TRUE. If both are TRUE, or both are FALSE, the result is FALSE.

`=XOR(E2="Yes",F2="Yes")`

Amara came through a referral and not an agency, so only one test passes and the result is TRUE. Boris has neither, so FALSE. Dmitri has both, so FALSE, even though OR would say TRUE. Chipo, Esi and Grace each have exactly one, so TRUE. The results for rows 2 to 8 are TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE.

That makes XOR the right tool when two options must not overlap. Here a candidate should have exactly one source, and Dmitri's row is the one to investigate.

With three or more tests, XOR no longer means "only one". It means "an odd number are TRUE". Add the certificate column:

`=XOR(D2="Yes",E2="Yes",F2="Yes")`

Amara has two Yes answers, which is an even number, so the result is FALSE. Dmitri has three, which is odd, so TRUE. Esi has one, so TRUE. The rule is easy to remember: count the TRUE answers and ask if the count is odd.

## Combine AND, OR and NOT in one formula

The functions nest. Read from the inside out. Here is a rule for a referral or agency fee: pay it when the candidate is certified and came through either route:

`=AND(OR(E2="Yes",F2="Yes"),D2="Yes")`

The OR part covers the two routes. The AND then insists on the certificate. Amara, Chipo and Dmitri give TRUE. Esi came through an agency but has no certificate, so FALSE. Grace was referred but is not certified, so FALSE.

The order of the brackets changes the meaning. Move one and you get a different rule:

`=OR(AND(E2="Yes",D2="Yes"),F2="Yes")`

This pays for any agency candidate, even one without the certificate, because the OR lets the agency test pass on its own. Esi gives TRUE here. Say the rule out loud in words before you write it, then check one row where the two versions differ.

Keep the nesting shallow. If the formula runs past two levels, put each part in its own helper column. Each column then has a name you can read, and a mistake is easy to find.

## Logical functions inside IF

On their own, AND, OR, XOR and NOT only print TRUE or FALSE. Put one in the first slot of IF to return something readable. This is the main way people use them.

`=IF(AND(B2>=3,C2>=70),"Interview","Hold")`

Amara and Farid show Interview. Everyone else shows Hold. With OR:

`=IF(OR(C2>=90,B2>=8),"Fast track","Standard")`

Boris, Dmitri and Grace show Fast track. With NOT:

`=IF(NOT(D2="Yes"),"Needs certificate","Cleared")`

Boris, Esi and Grace show Needs certificate. And with XOR:

`=IF(XOR(E2="Yes",F2="Yes"),"One source","Check source")`

Rows 3, 5 and 7 show Check source, because those candidates have either no source or both. The [IF function guide](https://logicexcel.com/functions/if) covers the three slots, nesting and the common errors. If you find yourself nesting IF around several of these, the [IFS guide](https://logicexcel.com/functions/ifs) shows a flatter layout.

## Excel symbol for OR and AND

Programming languages write OR as a double bar and AND as a double ampersand. Excel has no such symbol. There is no `||` and no `&&`. You have two choices.

The first choice is the functions above. The second is arithmetic, which works because TRUE counts as 1 and FALSE as 0 when you add or multiply them. Multiply for AND:

`=(B2>=3)*(C2>=70)`

Amara gives 1 and Boris gives 0. The result is a number, not TRUE or FALSE, but IF treats 1 as TRUE and 0 as FALSE, so it works as a test. Add for OR, then check the sum is above zero:

`=(C2>=90)+(B2>=8)>0`

Boris gives TRUE, because one of the two parts is 1. Amara gives FALSE. Without the `>0` you would get 0, 1 or 2, and 2 would be a surprise.

The arithmetic style is common in array formulas and in SUMPRODUCT, where AND and OR do not work on whole arrays one row at a time. For everyday tests the functions read better.

One trap deserves its own warning. A chained comparison does not work the way it does in maths:

`=3<B2<10`

Excel works left to right. For Amara, `3<B2` is TRUE, and then it asks whether TRUE is less than 10. Excel ranks logical values above numbers, so the answer is FALSE, even though 5 sits between 3 and 10. The right way to write "between" is `=AND(B2>3,B2<10)`, which gives TRUE.

## Logical functions compared with their alternatives

The logical functions answer a question for one row. Other tools do similar jobs in other shapes.

| Need | Best tool | Why |
|---|---|---|
| Several conditions in one row, TRUE or FALSE answer | AND, OR, XOR | Direct, readable |
| Several conditions, a word or number as the answer | IF with AND or OR | One cell does it |
| Many ordered outcomes | IFS | A flat list instead of a nest |
| Count rows that meet several conditions | COUNTIFS | Works on the whole range without a helper column |
| Total rows that meet several conditions | SUMIFS | Same, for sums |
| Exclude a condition | NOT or `<>` | Reverses a test |

COUNTIFS is the one people forget. To count the candidates with at least 3 years and a score of 70 or more, you do not need a helper column of AND results:

`=COUNTIFS(B2:B8,">=3",C2:C8,">=70")`

Amara and Farid pass both tests, so the count is 2. Our guide to [COUNTIFS](https://logicexcel.com/functions/countifs) explains the criteria rules, and [SUMIFS](https://logicexcel.com/functions/sumifs) does the same for totals.

COUNTIFS joins its criteria with AND only. For an OR count, add two COUNTIFS together, and subtract the overlap if a row can match both.

## Versions and other languages

AND, OR and NOT are in every version of Excel, in Excel for the web and in Excel for Mac. XOR was added in Excel 2013, so it is also present in Excel 2016, 2019, 2021, 2024 and Microsoft 365, but not in Excel 2010 or earlier.

Function names follow the language of your Excel. If you open a file from a colleague who uses another language, the names look different even though they behave the same:

| English | German | French | Spanish |
|---|---|---|---|
| AND | UND | ET | Y |
| OR | ODER | OU | O |
| NOT | NICHT | NON | NO |

Those Excel editions often use a semicolon between arguments instead of a comma, so a formula you copy from this page may need its commas swapped. The tests and the logic are the same.

## Logical function errors and how to fix them

| What you see | Cause | Fix |
|---|---|---|
| #VALUE! | All the arguments are text or empty, as in `=AND(E2,F2)` where both cells hold the word Yes or No | Compare the text to something, as in `E2="Yes"` |
| #NAME? | A mistyped function name, or XOR in Excel 2010 | Check the spelling and the version |
| #VALUE! or a one-row answer on a range test | `=AND(C2:C8>=50)` in Excel 2019 or earlier, typed without Ctrl+Shift+Enter | Press Ctrl+Shift+Enter, or use COUNTIF to count the failures |
| FALSE when you expected TRUE | A text number, a trailing space, or a chained comparison like `3<B2<10` | Convert the text, use TRIM, and use AND for between tests |
| "Too many arguments" | NOT given two tests | NOT takes one test. Wrap two tests in AND or OR first |

Text arguments need a note. If a referenced cell or range holds a mix of logical values and text, the text is ignored. Text typed straight into the formula, such as `=AND("Yes")`, returns #VALUE!. If every argument is text or empty, AND, OR and XOR return #VALUE!. That is why a bare cell with the word Yes inside fails, and a comparison like `E2="Yes"` works.

## What learners get wrong

Between 26 September and 3 November 2026, learners made 4,437 first attempts across our [AND, OR, XOR lesson](https://logicexcel.com/practice/17), and 77.7% were right. These are first checks of a screen in a page view, not people. The mistakes cluster around two ideas: what XOR does, and what AND needs.

The XOR screen was the hardest. Of 429 first attempts, 64.3% were right. The screen asks what XOR returns when more than one argument is true, and the answer is FALSE. A total of 137 first attempts said TRUE. That fits a reading of XOR as a looser OR. The word to remember is "exclusive": a second TRUE cancels the first. A pair of attempts typed `=XOR(1<2,3<4)` as the answer. Both of those tests are true, so the function returns FALSE.

The next screen combines the ideas. It asks what a NOT around an XOR returns, out of 434 first attempts with 68.9% right, and the correct answer is TRUE. Here 120 first attempts said FALSE. The fix is to work from the inside out: find the XOR first, then flip it. The screen's answer is TRUE, which tells you the XOR inside was FALSE.

The AND screens look easy and still caught a lot of people. Of 467 first attempts at an AND with two true tests, 69.2% were right. Sixty-seven said FALSE. Another 53 typed the formula `=AND(1=1,1<2)` back instead of its result. When a screen asks "would this return true or false", the answer is the one word. Another AND screen mixes a number test with a text test. Of 441 first attempts, 72.8% were right, and 104 said TRUE. AND needs every test to pass. At least one of the two tests fails, and that alone makes the whole answer FALSE.

The [practice lesson on AND, OR, XOR, TEXTJOIN, LARGE and SMALL](https://logicexcel.com/practice/20) mixes the family with other functions. It drew 3,292 first attempts, and 75.6% were right. On its NOT screen, 320 first attempts, 74.4% were right, and 65 said TRUE. The correct answer is FALSE, which means the cell inside holds a true value and NOT flips it. The fix is the same as before: say what the inside returns, then reverse it.

## A worked job: the hiring shortlist

Your manager wants the seven candidates sorted into who to interview, who to fast-track and which source records need cleaning. Build it in four steps.

1. **Flag the interview list.** A candidate needs 3 years and a score of 70:

   `=IF(AND(B2>=3,C2>=70),"Interview","Hold")`

   Amara and Farid show Interview. The other five show Hold.

2. **Add the fast track.** A very high score or a long career skips the queue:

   `=IF(OR(C2>=90,B2>=8),"Fast track","Standard")`

   Boris, Dmitri and Grace are fast-tracked.

3. **Check the sources.** Each candidate should have exactly one source. Flag the exceptions:

   `=IF(XOR(E2="Yes",F2="Yes"),"One source","Check source")`

   Boris, Dmitri and Farid show Check source. Boris and Farid have no source, and Dmitri has two.

4. **Count the interviews.** Count without a helper column:

   `=COUNTIFS(B2:B8,">=3",C2:C8,">=70")`

   The answer is 2, which matches the two Interview rows from step 1.

The four columns answer four questions, and each uses the logical function that matches the question. If the rules change, you edit one number in one place.

## Practice the logical functions

Reading a truth table is easy and writing the formula is not, so type them. Open [Practice Lesson 17](https://logicexcel.com/practice/17) and work through AND, OR and XOR one at a time. The page already carries the exercise, so type the formula rather than read on. Then try [Practice Lesson 20](https://logicexcel.com/practice/20) for a mixed set, and [True & False](https://logicexcel.com/practice/48) to see how a comparison turns into TRUE or FALSE. After that, read about [conditional formatting formulas](https://logicexcel.com/functions/conditional-formatting-formulas), where the same tests can colour a row.

## FAQ

### What are the logical functions in Excel?

The main ones are AND, OR, NOT and XOR. Each returns TRUE or FALSE. AND needs all tests true, OR needs one, NOT flips a result, and XOR is TRUE when an odd number of tests are true. IF is usually grouped with them, because it uses their answers to return a value.

### How do I use the OR function in Excel?

Type `=OR(` then your tests separated by commas, such as `=OR(C2>=90,B2>=8)`. It returns TRUE if any one test is true and FALSE only when every test is false. To return a word instead of TRUE, place it inside IF: `=IF(OR(C2>=90,B2>=8),"Fast track","Standard")`.

### What is the symbol for OR in Excel?

There is none. Excel has no `||` operator. Use the OR function, or add the tests as numbers: `=(C2>=90)+(B2>=8)>0`. The plus sign works as OR because TRUE counts as 1 and FALSE as 0. The multiplication sign works as AND in the same way.

### What is the difference between OR and XOR?

OR is TRUE when at least one test is true, including when all are true. XOR is TRUE when an odd number are true. With two tests that means exactly one: if both are true, OR says TRUE and XOR says FALSE. XOR needs Excel 2013 or later.

### How do I write AND NOT in Excel?

Wrap the second test in NOT inside AND: `=AND(D2="Yes",NOT(F2="Yes"))` is TRUE when the first test passes and the second fails. You can also write the second test with the not-equal operator, `AND(D2="Yes",F2<>"Yes")`. Both give the same answer.

### Can AND and OR be used in the same formula?

Yes. Nest one inside the other, and read from the inside out: `=AND(OR(E2="Yes",F2="Yes"),D2="Yes")` means one of two routes and the certificate. Moving a bracket changes the rule, so test one row where the versions differ.

### Why does my AND formula return #VALUE!?

Every argument was text or empty, so AND found no logical value to work with. Compare the text to something, as in `E2="Yes"`, rather than passing the cell on its own. In Excel 2019 and earlier, an AND over a range also needs Ctrl+Shift+Enter.

### How do I make a between test with AND?

Use two comparisons inside AND: `=AND(B2>3,B2<10)`. Do not write `=3<B2<10`, because Excel works left to right and compares a logical value with 10, which gives the wrong answer. Use `>=` and `<=` when the end points should count.

## Sources

- [AND function, Microsoft Support](https://support.microsoft.com/en-us/office/and-function-5f19b2e8-e1df-4408-897a-ce285a19e9d9)
- [OR function, Microsoft Support](https://support.microsoft.com/en-us/office/or-function-7d17ad14-8700-4281-b308-00b131e22af0)
- [XOR function, Microsoft Support](https://support.microsoft.com/en-us/office/xor-function-1548d4c2-5e47-4f77-9a92-0533bba14f37)
