XOR Function

XOR Function

XOR Function

Returns TRUE when an odd number of logical tests are TRUE.

ExcelClash Team
PUBLISHED

Summary

The Excel XOR function returns TRUE when an odd number of logical tests are TRUE, and FALSE when the number of TRUE results is even.

Most people first meet XOR as an "either this or that, but not both" function. That is the most common use with two conditions. But with three or more conditions, XOR still follows the same core rule: it returns TRUE when the count of TRUE results is odd.

Purpose

Check for exclusive or odd TRUE results

Useful when one condition should pass, but two passing at the same time would be treated differently.

Return Value

TRUE or FALSE

Returns a logical result that can be used directly or inside formulas such as IF.

Syntax

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

Microsoft documents that XOR accepts from 1 to 254 conditions. Each argument should evaluate to a logical value such as TRUE or FALSE.

Arguments

  • logical1 - [required] The first logical test.
  • logical2... - [optional] Additional logical tests, up to 254 total arguments.

These arguments can be direct logical values, comparisons such as A1>10, or references that evaluate to TRUE or FALSE.

XOR vs Other Logical Functions

Function Main Idea Returns TRUE When Best Use
XOR Exclusive or odd-parity test An odd number of tests are TRUE Mutually exclusive logic and parity-style checks
OR Any match At least one test is TRUE Flexible pass conditions
AND All match Every test is TRUE Strict rule sets
NOT Reverse a result The original logical value is FALSE Inverting a condition

The most important difference is that XOR does not simply mean "one or the other" in every case. With two conditions, that is a good mental model. With more than two conditions, the real rule is odd versus even TRUE counts.

Using XOR

XOR is most useful when your model needs to detect an exclusive outcome. For example, one checkbox may be allowed, but not both. One sensor may be over a threshold, but if both are over the threshold, that means a different kind of issue. In those cases, XOR is often clearer than combining multiple AND, OR, and NOT checks manually.

Microsoft also notes that array or reference arguments containing text or empty cells ignore those values. But if a specified range contains no logical values at all, XOR returns #VALUE!. That is worth remembering when you point XOR at larger ranges or mixed data.

XOR fits naturally inside IF. For example, you can use it to return labels such as "Exactly one selected", "Conflict", or "Check required" based on whether the logic passes.

Example 1 - Check That Exactly One Option Is Selected

With two conditions, XOR is often used as a mutual-exclusion test.

=XOR(B1,C1)

This returns TRUE when one option is TRUE and the other is FALSE. If both are TRUE or both are FALSE, the result is FALSE.

Check Answer
Challenge #1
Target: Sheet1!F1
Exclusive Choice

In cell F1, check whether exactly one of B2 or C2 is TRUE with =XOR(B2,C2).

Example 2 - Detect a One-Sided Threshold Breach

XOR can compare two logical tests and confirm that only one of them passes.

=XOR(B1>100,C1>100)

This is useful when one breach should be flagged differently from a two-sided failure. It gives you a quick way to distinguish "only one side failed" from "both sides failed."

Check Answer
Challenge #2
Target: Sheet1!F2
Single Breach

In cell F2, check whether exactly one of B2 or C2 is greater than 100.

Example 3 - Test for an Odd Number of TRUE Results

With three or more inputs, XOR follows its full odd-count rule.

=XOR(B1,C1,D1)

This returns TRUE when 1 or 3 of the tests are TRUE, and FALSE when 0 or 2 are TRUE. That makes it useful when parity matters more than a simple yes-or-no check.

Check Answer
Challenge #3
Target: Sheet1!F3
Odd TRUE Count

In cell F3, test whether an odd number of B2, C2, and D2 are TRUE.

Example 4 - Compare Two Alternative Targets

XOR works well with comparisons against dynamic benchmarks.

=XOR(B2>=G2,C2>=H2)

This returns TRUE when one target is met but not both. It can be useful in scorecards, validation checks, or rules where only one success path should remain active.

Check Answer
Challenge #4
Target: Sheet1!F4
Target Comparison

In cell F4, check whether B2 meets G2 or C2 meets H2, but not both.

Conclusion Recap

  • Summary: XOR returns TRUE when an odd number of tests are TRUE.
  • Common use: With two inputs, it works as an either-or check where both should not happen together.
  • Advanced use: With more than two inputs, it becomes an odd-parity test.
  • Range behavior: Text and blanks in array or reference arguments are ignored.
  • Error note: If a referenced range contains no logical values, XOR returns #VALUE!.
  • Practical pairing: Combine XOR with IF to turn logic results into readable labels.
Tactical Arena
Select Scenario:
Share XOR Function!

Tell your friends about this post

Discussion

ExcelClash is an interactive platform designed to level up your Excel skills through real-world exercises and challenges. Sharpen your logic, solve real spreadsheet problems, and learn faster.

© 2026 ExcelClash, Inc. All rights reserved.