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.
Syntax =XOR(logical1, [logical2], ...)
=XOR(B1,B2)Arguments
| Name | Required | What to pass |
|---|---|---|
| logical1 | Required | The first test. |
| logical2 | Optional | More 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
| A | B | |
|---|---|---|
| 1 | Pickup | TRUE |
| 2 | Delivery | FALSE |
| 3 | Exactly one of two | TRUE |
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.