Highlight cells in a row where the value of a particular cell is different to that of the previous row

被刻印的时光 ゝ 提交于 2020-01-11 07:05:10

问题


I'd like to apply some conditional formatting where each cell of a row is compared to the cell in the previous row. If it differs then the row is highlighted.

I'm using Excel 2007. Is this even possible? If so could someone provide me with the steps to apply this to an entire table of data?


回答1:


Yes, it is possible. It was possible in previous versions of Excel, too.

The condition is very simple.

Select the data, starting from the second row of data (the third row counting from the header), bring up the condition formatting dialog, select "Formula" and enter =A3<>A2, =A3<>OFFSET(A3,-1,0) where A3 is the top-left cell of the selection.
Note the absence of dollar signs - Excel will automatically suggest them, so delete accordingly.

Because the reference is not absolute, the formatting will properly apply to the whole table.




回答2:


You can make it even more versatile, like this:

=INDIRECT(ADDRESS(ROW(), COLUMN()))<>INDIRECT(ADDRESS(ROW()-1, COLUMN()))

Here's how it works:

  • =ADDRESS(ROW(), COLUMN()) refers to the current cell (i.e. the one to be formatted).
  • Similarly, =ADDRESS(ROW()-1, COLUMN()) refers to the cell above the current cell. Then all I do is compare the two.


来源:https://stackoverflow.com/questions/5194286/highlight-cells-in-a-row-where-the-value-of-a-particular-cell-is-different-to-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!