Skip to Content

How to use Excel XOR Function (With Examples)

The XOR is a prebuilt logical function in Excel. It is used to perform “exclusive OR.”

The Excel XOR function returns the following outputs for the given two conditions:

  • TRUE only when one of the conditions is satisfied
  • FALSE only when both of the conditions are either satisfied or not satisfied

Suppose you are planning a summer learning program for students who passed only one subject, either Math or Science. It is not intended for students who passed or failed both subjects.

Refer to the following table.

Our formula would be as follows:

Where,

  • B2=”Pass” is the first condition to check if the given student passed the Maths exam
  • C2=”Pass” is the second condition to check if the given student passed the Science exam

Here’s the output,

Syntax

The Excel XOR function has the following syntax. It is mostly combined with the IF function to create complex formulas in Excel.

Where logical1 and logical2 represent conditions. You can use comparison operators to define conditions or criteria.

  • =” – Equal To
  • <“- Less Than
  • <=” – Less Than or Equal To
  • >” – Greater Than
  • >=” – Greater Than or Equal To
  • <>” – Not Equal To

Important Notes:

  • You can input up to 254 logical conditions
  • The function is not case-sensitive
  • It does not support wildcards
  • You may get a #VALUE error if no logical values are found or created

How to use the XOR Function in Excel

Download the example spreadsheet used to demonstrate the Excel XOR function in the upcoming section. Practice is the key to success!

Download Now

Example 1: The XOR Function Basics

Suppose that you own an online store. You are planning a special offer this summer to encourage new customers to try your premium products: Cherry and Lychee.

  • If a customer adds one of these premium fruits to their cart, they will get a 30% discount.
  • If any customer adds both of these fruits to their cart, they don’t get any discount.
  • No discount is applicable when neither of these products is in the cart.

Refer to the following customer data,

Here are the steps,

  • Select the cell D2
  • Type =XOR
  • Select the first option from the pop-up
  • Specify the first condition as B2=”Yes”
  • Type , on your keyboard
  • Specify the second condition as C2=”Yes”
  • Complete the bracket using ) on your keyword
  • Press the Enter key

Our final formula is as follows,

Where,

  • B2=”Yes” condition checks if the Cherry was added to the cart
  • B2=”Yes” condition checks if the Lychee was added to the cart

The results are displayed in the following image,

Takeaway

The XOR is a simple logical function with easy-to-use syntax. Please comment below if you are stuck or encounter any particular error while using the AND function. I will answer your questions as soon as possible.

Additional Resources:

  • Learn All Excel Logical Functions (With Examples)
  • IF Function in Excel
  • OR Function in Excel
  • NOT Function in Excel

Get an Office 365 Subscription to Access all the powerful Functions and Tools in Excel.