Does Excel have an Exclusive Or Function

bbbb1234

Board Regular
Joined
Aug 8, 2002
Messages
150
Office Version
  1. 365
Platform
  1. Windows
I hope most those who might answer this know what an exclusive OR is but just in case, here is a simple example...

A1 can be True or False
B1 can be True or False
C1 contains the exclusive OR function of A1/B1

So if...
A1=False, B1=False, then C1 = False
A1=False, B1=True, then C1 = True
A1=True, B1=False, then C1 = True
A1=True, B1=True, then C1 = False

Any ideas for the function that goes in C1? I can't find a built in function for this.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
You're right, Excel doesn't have a built-in XOR function, but VBA does, which makes it much easier to make your own. In a standalone module (preferably in an add-in, so you can use it whenever you want, you can enter this function:

Code:
Public Function ExOr(arg1 As Variant, arg2 As Variant)

    ExOr = arg1 Xor arg2

End Function

That way, if you want to hardcode one of the numbers instead of using a range, you can.

Hope that helps!
 
Upvote 0
doesn't seem right: not (a=b) is a so called NAND

exor is also 'easily' to implement:

=NOT(OR(NOT(OR(A1;B1));AND(A1;B1)))

;-)
Hans
 
Upvote 0
is indeed shorter.

I read A1=B1 as an AND but it is meant as comparision and thats why the above first 'algorithm' is correct!

:rofl:
 
Upvote 0

Forum statistics

Threads
1,223,665
Messages
6,173,662
Members
452,526
Latest member
azrcguy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top