[英]Conditional formatting of two rows in Excel through row comparison
Consider the following data: 考虑以下数据:
I would like to compare each cell in row 1 to the adjacent cell below in row 2, using red for inequality and green for equality. 我想将第1行中的每个单元格与第2行以下的相邻单元格进行比较,其中红色表示不平等,绿色表示相等。 A similar principle applies for rows 3 and 4. Ie, the output should be
类似的原理适用于第3行和第4行。即,输出应为
The data I have in reality have more rows and columns than in this toy example, so the less manual work that has to be done, the better. 实际上,与该玩具示例相比,我拥有的数据具有更多的行和列,因此,要做的手动工作越少越好。 The data I have are small enough that I would be fine pointing and clicking for results.
我拥有的数据足够小,可以很好地指向并单击以获取结果。 I've tried using Conditional Formatting for this, but haven't been able to figure out its formulas.
我已经尝试过使用条件格式设置,但是还没有弄清楚它的公式。
I would prefer a non-VBA solution if possible. 如果可能,我希望使用非VBA解决方案。
I don't necessarily need the provided solution to be general, as long as it's clear to me how it can be generalized. 只要我很清楚如何将其概括,就不一定需要所提供的解决方案是通用的。 Ie, it needs to be obvious how to adjust the solution when the data start at a different row or column, other than cell
A1
. 即,当数据从单元格
A1
以外的其他行或列开始时,如何调整解决方案应该很明显。
The following formula will format all pairs of nonequal cells: 下面的公式将格式化所有不相等的单元格对:
=OFFSET(A1,1-2*MOD(ROW()+1,2),0)<>A1
Create a second rule with <>
replaced with =
to format the equal cells. 创建第二个规则,将
<>
替换为=
以格式化相等的单元格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.