EXCEL XOR multiple bits


Okay I have two cells with a string of bits 0111010 and 0101011. I want to XOR the two together so that the resulting cell would be 0010001.

I know you can use this for boolean values


but it doesn't work for a string of bits.

Best Solution

You need to use VBA to do this. If you open VBA, create a new Module and enter the function

Public Function BITXOR(x As Long, y As Long)
    BITXOR = x Xor y
End Function

You can then use the DEC2BIN and BIN2DEC to convert from binary to decimal to run this function. For example:

Cell A1 = 0111010

Cell A2 = 0101011