## Summary

The XOR function performs what is called "exclusive OR". With two logical statements, XOR returns TRUE if either statement is TRUE, but returns FALSE if both statements are TRUE. If neither is TRUE, XOR also returns FALSE.

## Purpose

Perform exclusive OR

TRUE or FALSE

## Arguments

• logical1 - An expression, constant, or reference that evaluates to TRUE or FALSE.
• logical2 - [optional] An expression, constant, or reference that evaluates to TRUE or FALSE.

## Syntax

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

## How to use

The XOR function performs what is called "exclusive OR", in contrast to the "inclusive OR" performed by the OR function. Whereas the OR function returns true if any input is TRUE, XOR only returns TRUE in specific cases. In the simplest case, with just two logical statements, XOR returns TRUE only if one of the logicals is TRUE. If both values are TRUE, XOR returns FALSE.

The concept of exclusive OR is more common in the world of programming. In plain English, you can think of a sentence like this: "I'm either going to visit New York or San Francisco this summer". Nothing prevents the speaker from visiting both, but the meaning is clearly that they plan to visit only one or the other. If they visit one or the other, the original statement is TRUE. If they visit neither or both, the original statement is FALSE.

### Example #1 - two values

In the example shown, the formula in D5, copied down, is:

``````=XOR(B5,C5)
``````

At each row, XOR only returns TRUE when B5 and C5 contain a single TRUE or equivalent value.

### Example #2 - more than two values

With more than 2 values, the behavior of XOR is a bit different. With three or more logicals, XOR only returns TRUE when the number of TRUE values is odd, as shown in the following example:

In this example, XOR is given a range with five values in a single argument instead of five separate arguments. The formula in G6 copied down is:

``````=XOR(B6:F6)
``````

The result is TRUE only when the number of TRUE values columns B through F is an odd number.

### Notes

• Logical arguments must evaluate to TRUE or FALSE, 1 or 0, or be references that contain logical values.
• XOR returns #VALUE! if no logical values are found.
• With more than two logicals, XOR returns TRUE when the number of TRUE logicals is odd, and FALSE if not.
• XOR was introduced in Excel 2013.

Author

### Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.