# Thread: Exclusive Or function (Office 2003)

1. ## Exclusive Or function (Office 2003)

Hello

Is it possible to create an Exclusive Or function in Excel? I'm working on a project that has a requirement to use this function along with a few other logic operators. If Excel will allow me to genrate an XOR then it makes life a little easier, if not I'll figure it out another way.

Thanks.

Ian

2. ## Re: Exclusive Or function (Office 2003)

If you want to use a logical XOR function (as opposed to a bitwise XOR function), you can create this custom function in your Personal.xls:

Public Function MyXOR(Arg1 As Variant, Arg2 As Variant) As Variant
MyXOR = CBool(Arg1) Xor CBool(Arg2)
End Function

Use in a formula like this:

=MyXOR(A1,A2)

Note: you cannot name this function XOR since that is already a VBA function.

3. ## Re: Exclusive Or function (Office 2003)

You can try the following:

<code>=AND(OR(A1,B1),NOT(AND(A1,B1)))</code>

4. ## Re: Exclusive Or function (Office 2003)

Another (not quite equivalent) possibility is to combine OR and AND:

=OR(A1,A2)-AND(A1,A2)

5. ## Re: Exclusive Or function (Office 2003)

This also works if the cells are both boolean, though if you have numbers in them it can fail.
=A1<>A2

Steve

6. ## Re: Exclusive Or function (Office 2003)

Great

Thanks for the help, all methods seem to work fine.

Ian

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•