问题
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 -
- Condition - Apply the fill in color only if all of the rules apply in the AND function
- $B2<>"" - checking that the first cell in the selected range is not blank.
- $C2<>"" - checking that the first cell in the selected range is not blank.
- $B2=$C2 - checking that the first two cells in the selected range are equal.
- 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