How to highlight the cell by conditional formatting by comparing two columns ignoring BLANK match?

北慕城南 提交于 2019-12-11 04:36:13

问题


I am trying to highlight the cell by conditional formatting by comparing two columns B and C

The condition is like to ignore BLANKS even if both columns have blanks on same row ,only to highlight the matching values So I wrote

=AND(B2=C2,C2<>"")

Please note the empy cells are not empty . If we click on empty cell , there's a hidden IF formula .But the value of cell is blank.

Its not working . Pls help


回答1:


Solution

=AND($B2<>"",$C2<>"",$B2=$C2)

Follow the steps in the below GIF to see how to use it - Conditional Formatting GIF

The logic

Fixate only the columns B and C, and make sure that you apply the rule on the first cells of the selected range, in this case it's row number 2. Excel will look interpret the formula this way -

  1. Condition - Apply the fill in color only if all of the rules apply in the AND function
  2. $B2<>"" - checking that the first cell in the selected range is not blank.
  3. $C2<>"" - checking that the first cell in the selected range is not blank.
  4. $B2=$C2 - checking that the first two cells in the selected range are equal.
  5. Apply the same rule for the rest of the selected range according to given fixation - columns B and C.

According to 5 - Excel loops over your selected range like this -

=AND($B3<>"",$C3<>"",$B3=$C3)
=AND($B4<>"",$C4<>"",$B4=$C4)
...
=AND($B9<>"",$C9<>"",$B9=$C9)

That's an awesome magic trick in Excel's conditional formatting.

For practice purposes, I suggest you try highlighting the whole line according to the same condition. And I also suggest you try to fixate $B$2 and $C$2 - Excel will interpret your formula only on these cells because you fixated it on them, that's a common mistake so watch out.

I hope it helps




回答2:


Use this formula in conditional formatting rule:

=IF(AND(B2=C2,C2<>""),TRUE)


来源:https://stackoverflow.com/questions/40765719/how-to-highlight-the-cell-by-conditional-formatting-by-comparing-two-columns-ign

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