ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Logic
  3. XOR Function in Excel: Exactly One Condition True

XOR Function in Excel: Exactly One Condition True

By ExcelReady Team·Updated November 1, 2026·7 min read

The short answer

XOR returns TRUE when exactly one of two conditions is TRUE, and FALSE when both are TRUE or both are FALSE. For example, =XOR(B2="Yes",C2="Yes") flags orders that are paid but not shipped, or shipped but not paid. With three or more conditions, XOR returns TRUE when an odd number of them are TRUE. It needs Excel 2013 or later.

Key takeaways

  • XOR means exclusive OR: one or the other, but not both.
  • With two conditions, XOR is TRUE when exactly one is TRUE. OR is also TRUE when both are.
  • With three or more conditions, XOR is TRUE when an odd number are TRUE, not only when exactly one is.
  • For exactly one of many, count the TRUE tests instead: =COUNTIF(B2:D2,"Yes")=1.
  • Wrap XOR in IF to show a label such as Check or OK instead of TRUE or FALSE.
On this page+
  1. What does the XOR function do?
  2. XOR example: find orders that don't match
  3. How to use XOR with IF
  4. XOR with numbers
  5. The trap: XOR with three or more conditions
  6. XOR vs OR and other ways to write it
  7. Common XOR mistakes
  8. Where XOR helps in real sheets
  9. Practise it

The XOR function in Excel answers the question "is exactly one of these true?". It returns TRUE when one condition is TRUE and the other is FALSE, and FALSE when both match. That makes it a quick way to spot mismatches, such as an order that was paid but never shipped. This guide shows how XOR works, how it differs from OR, and the one trap with three or more conditions.

What does the XOR function do?#

XOR stands for "exclusive OR": one or the other, but not both. Its syntax is:

Excel formula
=XOR(logical1, [logical2], ...)

Each argument is a logical test, which is any expression that gives TRUE or FALSE, such as B2="Yes" or C2>100. You can give up to 254 of them. XOR is available in Excel 2013 and later, including Microsoft 365 and Excel for the web.

With two conditions, the result follows this truth table:

Condition 1Condition 2ORXOR
TRUETRUETRUEFALSE
TRUEFALSETRUETRUE
FALSETRUETRUETRUE
FALSEFALSEFALSEFALSE

The only row where OR and XOR differ is the first one: when both conditions are TRUE, OR says TRUE and XOR says FALSE. The guide to AND, OR and NOT covers the other logical functions.

XOR example: find orders that don't match#

XOR is most useful for finding rows where two things should agree but don't. In this order list, every order should be both paid and shipped, or neither:

ABCD
1OrderPaidShippedMismatch?
21001YesYes
31002YesNo
41003NoNo
51004NoYes
61005YesYes
71006YesNo

In D2, type this and fill down to D7 (Windows: Ctrl+D; Mac: ⌘D):

Excel formula
=XOR(B2="Yes",C2="Yes")

The results are FALSE, TRUE, FALSE, TRUE, FALSE, TRUE. Orders 1002 and 1006 are paid but not shipped, and order 1004 was shipped without payment. Orders where both columns agree, whether Yes and Yes or No and No, return FALSE.

The same idea works for two reviewers who should agree (=XOR(B2="Approve",C2="Approve")), or a form where a person should tick exactly one of two boxes.

How to use XOR with IF#

TRUE and FALSE are fine for checking, but a label is easier to read. Put XOR in the test of IF:

Excel formula
=IF(XOR(B2="Yes",C2="Yes"),"Check","OK")

Now the column shows Check for orders 1002, 1004 and 1006, and OK for the rest. IF returns its second argument when the test is TRUE and its third when the test is FALSE. If you want to filter or count the problem rows later, a clear word like Check is easier to work with than TRUE. For more on combining logic with IF, see IF with OR and IF with AND.

XOR with numbers#

The tests inside XOR can be any comparison, not only text. Say a bonus applies to a rep who beat the sales target or the new-customer target, but not both, because hitting both earns a different, bigger award:

Excel formula
=XOR(B2>=50000,C2>=10)

If B2 is 62000 and C2 is 8, only the first test is TRUE, so XOR returns TRUE. If B2 is 62000 and C2 is 12, both are TRUE, so XOR returns FALSE. To test a value inside a range rather than above a line, see IF between two numbers.

The trap: XOR with three or more conditions#

With three or more conditions, XOR returns TRUE when an odd number of them are TRUE, not when exactly one is. That surprises many people:

Tests that are TRUEXOR result
0 of 3FALSE
1 of 3TRUE
2 of 3FALSE
3 of 3TRUE

So =XOR(TRUE,TRUE,TRUE) returns TRUE. If you need "exactly one of these three cells says Yes", count the matches instead:

Excel formula
=COUNTIF(B2:D2,"Yes")=1

This returns TRUE only when one cell in B2:D2 is Yes. For tests that aren't simple matches, add them up. In Excel, TRUE counts as 1 and FALSE as 0 when you add them:

Excel formula
=(B2>100)+(C2>100)+(D2>100)=1

XOR vs OR and other ways to write it#

Use OR when "at least one" is the rule, and XOR when "one but not both" is the rule. The OR function guide covers OR in detail, and the article on AND vs OR compares those two.

For two conditions, you can also write XOR without the function. Two tests are "exclusive" when their results differ, so <> (not equal to) does the same job:

Excel formula
=(B2="Yes")<>(C2="Yes")

This works in every version of Excel, which helps if a file must open in Excel 2010. XOR is easier to read, though, so use it when you can.

To count the mismatched orders in one cell, count each kind of mismatch and add them:

Excel formula
=COUNTIFS(B2:B7,"Yes",C2:C7,"No")+COUNTIFS(B2:B7,"No",C2:C7,"Yes")

That gives 2 + 1 = 3.

Common XOR mistakes#

These are the problems that come up most:

  1. Expecting "exactly one" with three or more tests. XOR checks for an odd number. Use COUNTIF or added tests instead.
  2. Forgetting quotes around text. B2=Yes gives #NAME?. Write B2="Yes".
  3. Using XOR where OR is meant. If both conditions being TRUE should also pass, XOR gives the wrong answer for those rows.
  4. Old Excel versions. XOR returns #NAME? in Excel 2010 and earlier. Use the <> version there.

Where XOR helps in real sheets#

XOR is not an everyday function, but it shines in data checks. Three common uses:

  • Mismatch flags. Two columns that should agree, like Paid and Shipped. =XOR(B2<>"",C2<>"") also flags rows where only one of two cells is filled in, such as a start date with no end date.
  • Either-or rules. A discount for members or for coupon holders, but not both.
  • Reviewer disagreement. Two approvers who should reach the same decision.

In a test, the question rarely names XOR. Look for wording such as "one or the other but not both" or "exactly one of the two". For two conditions, that is XOR.

Practise it#

XOR is easy once AND, OR and NOT feel natural. Practise AND, OR and NOT in a live spreadsheet: you type each logical test and the lesson checks it instantly. Then try the exercise on this page and flag the order that was paid but not shipped.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Order 1002 is paid but not shipped. In D3, write a formula that shows Check when exactly one of B3 and C3 is Yes, and OK otherwise. Use IF with XOR.

fx
ABCDE
1
Order
Paid
Shipped
Status
2
1001
Yes
Yes
3
1002
Yes
No
4
1003
No
No
5
1004
No
Yes
6
1005
Yes
Yes
7
1006
Yes
No
8
9
10

Tip: Inside IF, write XOR(B3="Yes",C3="Yes") as the test, then "Check" and "OK" as the two results.

Practise this in a lesson

LessonAND, OR and NOTCheck several conditions at once with AND and OR, flip a result with NOT, and combine them inside IF.Function guideORReturn TRUE when any condition is met with Excel's OR. Flag tickets, match one of several values and combine OR with IF. Practice it live.

Frequently asked questions

What does XOR do in Excel?

+

XOR checks two or more conditions and returns TRUE when an odd number of them are TRUE. With two conditions, that means exactly one is TRUE. If both or neither are TRUE, it returns FALSE.

What is the difference between OR and XOR in Excel?

+

OR returns TRUE when at least one condition is TRUE, including when both are. XOR returns FALSE when both are TRUE. The two only differ in that one case.

Which Excel versions have XOR?

+

XOR is available in Excel 2013 and later, including Excel 2016, 2019, 2021, Microsoft 365 and Excel for the web. In Excel 2010 or older it returns #NAME?.

How do I check that exactly one of three cells is Yes?

+

Don't use XOR, because XOR is also TRUE when all three are Yes. Count the matches instead: =COUNTIF(B2:D2,"Yes")=1 returns TRUE only when exactly one cell says Yes.

Can I use XOR with IF?

+

Yes. Put XOR in the test of IF: =IF(XOR(B2="Yes",C2="Yes"),"Check","OK"). IF then shows Check when exactly one condition is TRUE and OK otherwise.

Sources

  • XOR function - Microsoft Support
  • OR function - Microsoft Support
  • AND function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. What does the XOR function do?
  2. XOR example: find orders that don't match
  3. How to use XOR with IF
  4. XOR with numbers
  5. The trap: XOR with three or more conditions
  6. XOR vs OR and other ways to write it
  7. Common XOR mistakes
  8. Where XOR helps in real sheets
  9. Practise it

Keep reading

Logic· 6 min read

IF with OR in Excel: Pass When Any Condition Is Met

To pass when any one of several conditions is true, put OR inside IF: =IF(OR(B2="VIP",C2>=500),"Free shipping", "Standard"). OR returns TRUE if at least one condition is true, and FALSE only when all of them are false. IF then shows the result you choose. Each condition must be written in full, even when it tests the same cell.

Comparisons· 7 min read

AND vs OR in Excel: All Conditions or Any

AND returns TRUE only when every condition is true. OR returns TRUE when at least one condition is true. Use AND for strict rules, like sales of 50,000 or more and a rating of 4 or more. Use OR for "either" rules. Both usually sit inside IF, as in =IF(AND(B2>=50000,C2>=4),"Bonus","No").

Logic· 7 min read

AND, OR and NOT in Excel With IF

AND returns TRUE only when every condition is TRUE. OR returns TRUE when at least one condition is TRUE. NOT flips TRUE to FALSE and FALSE to TRUE. On their own they give TRUE or FALSE, so you usually put them inside IF's test, like =IF(AND(C2>=50000,D2>=4.5),"Bonus","No bonus").

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free