Conditional Formatting of a value based on Yes or NO

旧城冷巷雨未停 提交于 2019-12-25 02:22:42

问题


I have two ROWS, one has values and the other Yes or NO. I want the values in ROW 1 to be colored according to whether Yes or NO in ROW 2 in the corresponding column. For example:

   ROW 1  XXXX|XXXX|XXX|XXXX  
   ROW 2  YES | NO |YES| NO

There are no conditions to why ROW 1 should be yes or no, it's just the way it is.

Is it possible?


回答1:


In conditional formatting, use this option:

And write this formula:

=If(B2="Yes",1,0)

And assuming your data is like this:

So, the highlight in Row1 changes depending on the value in Row2.
Hope this helps.
Note:
Remember, you only apply the formatting in A2 then just copy and paste format to other cells.




回答2:


Since the Conditional Formatting tag wiki summary mentions Excel I take it that is the relevant software. Since OP mentions “the condition of Yes or NO” I take it formatting is required for both possibilities. I take it that the leftmost XXXX is in A1.

The simplest way may be to select Row1, which should automatically set the appropriate Applies to range, and apply a Conditional Formatting formula rule (required since the cell to be formatted is not the trigger for the formatting) of:

=A1="YES"  

and formatting of choice (green highlight would be conventional).

The “NO” condition might be handled by simply formatting all of Row1 with ‘standard’ format, again being convention this might be red fill. The CF rule would then just override this where Row2 does not contain “NO”.

However another possibility is that there may be some cells in Row2 that contain neither “Yes” nor “NO” and where that is so the cell immediately above should not be conditionally formatted. In that case just add another formula rule similar to the one above:

=A1="NO"  

but a different format (red fill).

Because the formatting is conditional there is no need for an IF construct, the formatting will only be triggered when the formula returns TRUE.



来源:https://stackoverflow.com/questions/21040841/conditional-formatting-of-a-value-based-on-yes-or-no

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