How to Use the XOR Function in Excel

Today, let’s delve into a logical function that might not be frequently used but proves to be exceptionally useful in certain contexts—the XOR function. XOR stands for “exclusive or” and is designed to return TRUE if an odd number of arguments are TRUE, and FALSE otherwise. This functionality is especially beneficial when working with binary data or when you need to compare multiple conditions. We will discuss how the XOR function operates both in Microsoft Excel and Google Sheets.

Microsoft Excel

In Excel, the syntax for the XOR function is straightforward:

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

The function accepts up to 254 logical conditions, each separated by commas. Below is an example demonstrating the XOR function:

Formula Result
=XOR(TRUE, TRUE) FALSE
=XOR(TRUE, FALSE) TRUE

The example clearly illustrates that the XOR function returns TRUE only when the number of TRUE conditions is odd.

Google Sheets

The syntax for the XOR function in Google Sheets is identical to that in Excel:

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

Consider the following example in Google Sheets:

Formula Result
=XOR(1=1, 2=2) FALSE
=XOR(1=1, 2=3) TRUE

Similar to Excel, the XOR function in Google Sheets returns TRUE only when an odd number of conditions evaluate to TRUE.

In summary, the XOR function is exceptionally useful for evaluating multiple conditions where the desired outcome is a TRUE result for exactly one TRUE condition. This can be particularly valuable in complex logical evaluations and data validation scenarios.

More information: https://support.microsoft.com/en-us/office/xor-function-1548d4c2-5e47-4f77-9a92-0533bba14f37

Other functions
Returns TRUE if all of its arguments are TRUE
Returns the logical value FALSE
Specifies a logical test to perform
Returns a value you specify if a formula evaluates to an error; otherwise, returns the result of the formula
Returns the value you specify if the expression resolves to #N/A, otherwise returns the result of the expression
Checks whether one or more conditions are met and returns a value that corresponds to the first TRUE condition
Reverses the logic of its argument
Returns TRUE if any argument is TRUE
Evaluates an expression against a list of values and returns the result corresponding to the first matching value If there is no match, an optional default value may be returned
Returns the logical value TRUE