--- title: Excel updated: 2022-02-14 06:58:59Z created: 2022-01-08 13:18:07Z --- # 位反 无直接函数,可间接实现 bitxor为位异或,Byte取反即与0xFF(255)异或 # 高亮相同数值的单元格 方法有二 一,选择待处理区域,新建条件格式,规则为“使用公式确定要设置格式的单元格”,公式为`=A1=CELL("contents")`,设置高亮背景色。关闭后点选单元格按F9刷新即可。 二,需要宏支持。宏代码如下 ```vb Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Count <> 1 Then Exit Sub Dim rng As Range Dim cnt cnt = 0 If Target.Count = 1 And Target <> "" Then Cells.Interior.ColorIndex = -4142 For Each rng In UsedRange If rng = Target.Value Then cnt = cnt + 1 rng.Interior.ColorIndex = 44 End If Next If cnt = 1 Then Target.Interior.ColorIndex = -4142 'If cnt > 1 Then MsgBox (cnt) End If End Sub ```