# XOR function in Excel

> XOR returns TRUE when an odd number of its conditions are TRUE.

Source: https://spreadsheetpractice.com/functions/xor · Updated October 28, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on November 20, 2026

## Quick answer

- **What it does:** XOR returns TRUE when an odd number of its conditions are TRUE.
- **Syntax:** `=XOR(logical1, [logical2], ...)`
- **Most common use:** `=XOR(B2="Yes",C2="Yes")` returns FALSE (Both are TRUE, so there is no mismatch: FALSE)
- **Available in:** Excel 2013 and later
- **Category:** [Logical functions](https://spreadsheetpractice.com/functions/category/logic)
- **Returns:** TRUE if an odd number of arguments are TRUE, otherwise FALSE.
- **Google Sheets:** Available in Google Sheets.

## What it does

XOR returns TRUE when an odd number of its conditions are TRUE. With two conditions that means "one or the other, but not both", which is useful for spotting records that disagree with themselves: an order marked shipped with no tracking number, or a discount on an order too small to qualify.

## Syntax

`=XOR(logical1, [logical2], ...)`

| Argument | Required? | What it is |
|---|---|---|
| `logical1` | Required | The first condition. |
| `logical2` | Optional | More conditions, up to 254 in total. |

## Examples

Each result was calculated by running the formula on the sample sheet.

| Cell | Formula | Result | What it shows |
|---|---|---|---|
| D2 | `=XOR(B2="Yes",C2="Yes")` | FALSE | Both are TRUE, so there is no mismatch: FALSE |
| D3 | `=XOR(B3="Yes",C3="Yes")` | TRUE | Shipped without tracking: exactly one is TRUE |
| D4 | `=IF(XOR(B4="Yes",C4="Yes"),"Check","OK")` | OK | Inside IF to label the row |

### The sample sheet

Every formula above runs on this data:

|  | A | B | C | D |
|---|---|---|---|---|
| 1 | Order | Shipped | Has tracking | Result |
| 2 | K-210 | Yes | Yes | FALSE |
| 3 | K-211 | Yes | No | TRUE |
| 4 | K-212 | No | No | OK |

## Common mistakes

| What you see | Why, and how to fix it |
|---|---|
| Expecting "exactly one" with three conditions | With three conditions XOR is TRUE when one or all three are TRUE. To require exactly one, count them: =(B2="Yes")+(C2="Yes")+(D2="Yes")=1. |
| Using XOR where OR is meant | OR is TRUE when both conditions are TRUE; XOR is FALSE in that case. Use XOR only when "both" should count as a problem. |
| #NAME? | XOR arrived in Excel 2013. In older versions, compare the two tests directly: =(B2="Yes")<>(C2="Yes"). |

## Tips

- For two conditions, XOR(a,b) gives the same answer as a<>b.

## Related functions

- [OR](https://spreadsheetpractice.com/functions/or): OR returns TRUE when at least one of its conditions is TRUE.
- [AND](https://spreadsheetpractice.com/functions/and): AND returns TRUE only when every condition you give it is TRUE.
- [NOT](https://spreadsheetpractice.com/functions/not): NOT flips a logical value: TRUE becomes FALSE and FALSE becomes TRUE.

## Questions

### What does XOR mean in Excel?

Exclusive OR: TRUE when one condition is TRUE but not both. With more than two conditions it is TRUE when an odd number of them are TRUE.

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

OR is TRUE if any condition is TRUE, including all of them. XOR is FALSE when both of two conditions are TRUE.

## Practice

A graded XOR exercise ("Discount rule check") is on [the XOR page](https://spreadsheetpractice.com/functions/xor). It is checked instantly, then re-checked on changed data.

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
