XOR function

  • Applies to: Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel for the web, Excel 2019, Excel 2016, Excel 2019 for Mac, Excel 2013, Excel 2016 for Mac, Excel for Mac 2011.

The XOR function secures a logical Exclusive Or of all arguments.

Syntax

XOR(logical1, [logical2],…)

The XOR function syntax contains the stated arguments.

  • Logical1, logical2,…  –  Logical 1 is mandatory, forthcoming logical values are optional. 1 to 254 conditions you are looking to test that can be either TRUE or FALSE, and can comprise logical values, arrays, or references.

Remarks

  • The arguments have to evaluate to logical values like TRUE or FALSE, or in arrays or references that include logical values.
  • If an array or reference argument has text or empty cells, those values are not taken into account.
  • If the defined range includes no logical values, XOR returns the #VALUE! error value.
  • You can use an XOR array formula to check if a value has any results in an array.

Note: If you have a current version of Microsoft 365, then you can just type the formula in the top-left-cell of the output range, then press ENTER to verify the formula as a dynamic array formula. Otherwise, the formula must be stated as a legacy array formula by first choosing the output range, inputting the formula in the top-left-cell of the output range, and then pressing CTRL+SHIFT+ENTER to confirm it. Excel appends curly brackets at the start and end of the formula for you. For further details on array formulas, see Guidelines and examples of array formulas.

  • The outcome of XOR is TRUE whenever the number of TRUE inputs is odd and FALSE anytime the number of TRUE inputs is even.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter.

FormulaDescriptionResult
=XOR(3>0,2<9)Because both of the two tests evaluates to TRUE, FALSE is returned.FALSE
=XOR(3>12,4>6)Because all test results evaluate to FALSE, FALSE is returned. A minimum of one of the test results should evaluate to TRUE to return TRUE. FALSE

Need more help?

You can always ask an expert in the Excel Tech Community, get support in the Answers community, or suggest a new feature or improvement on Excel User Voice.

Also See

Excel Tutorial

Expand your Office skills

EXPLORE TRAINING

Got It

Get instant Excel help

CONNECT TO AN EXPERT NOW

Subject to Got It terms and conditions.

Leave a Reply

%d bloggers like this: