XOR Function

A logical function that returns TRUE or FALSE depending on the arguments
Functions  >  Logical  >  XOR

Overview of the Excel XOR Function

The Excel XOR function is a logical function that returns TRUE if an odd number of arguments are TRUE, and FALSE if an even number of arguments are TRUE. It is used for logical comparisons and is useful when you need to check whether exactly one of several conditions is met. The XOR function is often used in scenarios where you want to identify exclusive conditions. For more details, see Microsoft’s official XOR function documentation.

Syntax

=XOR(logical1, [logical2], …)

Arguments

  • logical1: The first condition or logical value to test.
  • logical2, …: Additional conditions or logical values to test. You can include up to 255 conditions.

Version

Available in Excel 2013 and later.

Purpose

The Excel XOR function evaluates multiple conditions and returns TRUE if an odd number of the conditions are TRUE, otherwise, it returns FALSE. It is most commonly used in situations where you need to compare several logical conditions and identify when only one condition is TRUE.

=XOR(logical1, [logical2], …)

Examples of the Excel XOR Function

Example 1: XOR Function for Two Conditions

Suppose you have two conditions: whether a student has passed an exam and whether the student has attended class. If exactly one of these conditions is true, you want the formula to return TRUE.

If we enter 75 in cell B4, and No in D5 we get:

Excel XOR Function Example 1

The formula we have in cell B6 is:

=XOR(B4 > 60, D4 = “Yes”)

Explanation:

  • If either B4 (score) is greater than 60 or D4 (attendance) is “Yes”, the formula returns TRUE.
  • If both are true or both are false, it returns FALSE.

Let’s see what difference adjusting the value from No to Yes makes:

We get FALSE, which is expected as both conditions are met (an even amount).

Example 2: XOR Function with Multiple Conditions

Now, suppose you want to check if only one of three conditions is true (e.g., test scores in B4, D4, and F4). You will use the XOR function to evaluate these conditions.

Excel XOR Function Example 3

The formula we have in cell B6 is:

=XOR(B4 > 50, D4 > 50, F4 > 50)

Explanation:

  • If only one of the three conditions is TRUE (e.g., only B4 > 50), it returns TRUE.
  • If two conditions are TRUE, it returns FALSE (even number).
  • If all three conditions are TRUE, it returns TRUE (odd number).

Example 3: XOR Function with Nested Conditions

In this example, you want to evaluate whether exactly one of two specific conditions is met: either the value in B4 is greater than 50, or the value in C4 is equal to “Yes”. You’ll nest this formula with an additional condition using IF.

The formula we have in cell B6 is:

=IF(XOR(B4 > 50, D4 = “Yes”), “Condition Met”, “Condition Not Met”)

Explanation:

  • If B4 > 50 or D4 = “Yes”, but not both, the formula returns “Condition Met”.
  • If both conditions are true or both are false, it returns “Condition Not Met”.

Notes

  • TRUE/FALSE Results: The XOR function evaluates logical values and returns either TRUE or FALSE, depending on the conditions you specify.
  • Comparison with Other Functions: XOR is often used in conjunction with functions like IF function and AND function to handle complex logical tests.
  • Official Documentation: For more examples and in-depth details, refer to Microsoft’s official XOR function documentation.

Author

Kyle Stott

Kyle Stott

Certified Microsoft Excel Expert

Kyle has worked professionally with Microsoft Excel for over a decade and has been consulting on and teaching best practices in Microsoft Excel to over 400 companies across 30+ countries.

Want to learn more?

Join My Excel Academy Today!

This All-Access Pass Includes:

Excel Academy Bundle

30-Day Money-Back Guarantee

Want to learn more?

Join My Excel Academy Today!

Excel Academy Bundle

All-Access Pass Includes:

30-Day Money-Back Guarantee

Excel Academy Bundle

Want to learn more?

Join My Excel Academy Today!

30-Day Money-Back Guarantee

This all-access pass includes:

Don’t hesitate – join now!

Have any questions?

View our Frequently Asked Questions or contact us!