Function · Logical

Excel XOR function

The Excel XOR function returns TRUE when an odd number of its tests are true. Pickup without delivery is TRUE. Pickup and delivery together is FALSE.

Excel 2013 and later, including Microsoft 365 and Excel for the web. Also in Google Sheets.

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

XOR
=XOR(B1,B2)

Arguments

NameRequiredWhat to pass
logical1RequiredThe first test.
logical2OptionalMore tests, up to 254. The result is TRUE when the count of TRUE results is odd.

Examples

A form that should have pickup or delivery, but not both

=XOR(B1,B2)

Result TRUE

=XOR(B1,B2)B3
Order
AB
1PickupTRUE
2DeliveryFALSE
3Exactly one of twoTRUE
A picture of the sheet, not a live calculator. Add a third TRUE test and the result flips back to TRUE, because three is odd.

XOR returns TRUE when the number of TRUE arguments is odd. Pickup TRUE and delivery FALSE is one TRUE, which is odd, so the result is TRUE. Both TRUE is two, which is even, so the result is FALSE. Both FALSE is FALSE as well. For a form with two choices, that is the test for exactly one of them.

The name does not mean exactly one once a third test is added. Three TRUE arguments are an odd count, so XOR returns TRUE. OR would return TRUE if any box is checked, including both. AND returns TRUE only when every box is checked. XOR is the parity test in between.