ID EN
#Logical

XOR

Excel Functions

Perform exclusive OR

Syntax

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

Arguments

Parameter Description
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.

Return Value

TRUE or FALSE

Details

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 origina

Examples

Example #1 - two values

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

EXCEL
=XOR(B5,C5)
Example #2 - more than two values

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:

EXCEL
=XOR(B6:F6)

See Also

OR NOT AND IF