如果列中的相邻单元格具有相同的值,则突出显示该单元格
问题描述:
我想遍历" Excel列,并且如果前一个或后一个单元格具有相同的值,请用颜色标记它.
I would like to "walk" through a Excel column and if the the preceding or following cell has the same value, mark it with a color.
例如:
Column A:
1 <~~~~ highlight
1 <~~~~ highlight
1 <~~~~ highlight
2
1
3 <~~~~ highlight
3 <~~~~ highlight
- 第一棵树1将被着色;
- 不是2,也不是接下来的1;和
- 最后3个再次着色.
我知道这应该以条件格式完成.但是如何?
I know this should be done in conditional formatting. But how?
答
使用公式进行条件格式化
Conditional formatting using a formula
=OR(A2=A1,A2=A3)
请注意,如果要始终使用相同的公式,则在列表的顶部需要一个虚拟行,在底部需要一个虚拟行来处理边缘情况.或者,对顶部(=A2=A3
)和底部(=A8=A7
)项目使用不同的公式.
Note that a dummy row is needed at the top of your list and another one at the bottom to deal with the edge cases if you want to use the same formula throughout. Alternatively, use different formulas for the top (=A2=A3
) and bottom (=A8=A7
) items.