EXCEL XOR多位 [英] EXCEL XOR multiple bits

查看:128
本文介绍了EXCEL XOR多位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我有两个单元格,一列0111010和0101011.我想把这两个组合在一起,使得最终的单元格将是0010001.



我知道你可以使用这个布尔值

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

但它不适用于一串位。

解决方案

您需要使用VBA才能执行此操作。如果您打开VBA,请创建一个新的模块并输入函数

 公共函数BITXOR(x As Long,y As Long)
BITXOR = x Xor y
结束函数

然后可以使用DEC2BIN和BIN2DEC将从二进制转换为十进制运行此功能。例如:



单元格A1 = 0111010



单元格A2 = 0101011

  = DEC2BIN(BITXOR(BIN2DEC(A1),BIN2DEC(A2)))


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

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

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

解决方案

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

=DEC2BIN(BITXOR(BIN2DEC(A1),BIN2DEC(A2)))

这篇关于EXCEL XOR多位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆