Excel XOR Function

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

Return value

TRUE or FALSE

Syntax

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

Arguments

Usage notes

The XOR function performs what is called "exclusive OR", as opposed to the "inclusive OR" performed by the OR function. Whereas the OR function returns true if any logical is TRUE, XOR returns TRUE in specific conditions. In the simplest case with two logical statements, XOR returns TRUE only if one of the logicals is TRUE, not if both logicals are TRUE.

The concept of exclusive OR is more familiar in the world of programing. 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 me from visiting both, but the meaning is clearly that I plan to visit only one or the other.

With more than 2 logicals

With more than 2 logicals, XOR only returns TRUE when the number of TRUE logicals is odd, as shown in the following example:

Notes:

 

Excel XOR Function

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

Return value

TRUE or FALSE

Syntax

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

Arguments

Usage notes

The XOR function performs what is called "exclusive OR", as opposed to the "inclusive OR" performed by the OR function. Whereas the OR function returns true if any logical is TRUE, XOR returns TRUE in specific conditions. In the simplest case with two logical statements, XOR returns TRUE only if one of the logicals is TRUE, not if both logicals are TRUE.

The concept of exclusive OR is more familiar in the world of programing. 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 me from visiting both, but the meaning is clearly that I plan to visit only one or the other.

With more than 2 logicals

With more than 2 logicals, XOR only returns TRUE when the number of TRUE logicals is odd, as shown in the following example:

Notes: