Excel365-根据两个字符串值有条件格式化行?
Excel Noob在这里。可以说我有一张床单。
。 | A | B | C | D |
---|---|---|---|---|
1 | ADAM | 3 | 否 | 2 |
BETTY | c | 13 | 是否 | 3 |
如果列 | CHRIS | 12 | 否 | 是 |
4 | Dave | 0 | 是 | 是 |
5 | Emma | 1 | 否 |
我想以多种方式有条件地突出显示细胞:
- 和列
d
都包含单词'yes'颜色行绿色(例如匹配行4) - 如果列
c
和列d
d 代码>不相同,为行黄色(例如匹配行2,3)染色, - 如果列
c
或d
是空的,请为红色红色(例如匹配行5)
我设置了两个工作表条件格式
= and(search(“是”,$ c2),$ c2)> 0,search(“是”,$ d2) > 0)
设置为绿色= $ c2<> $ d2
设置为黄色= or(isblank($ c2)($ c2),isblank($ d2) )
设置为红色
,但是我的结果好坏参半。我得到绿色的行,而C和D不在,C和D不同。我对第二或第三条规则没有任何格式。
我尝试直接匹配列值。 = $ C2 =“是”
不匹配,因此求搜索。
Excel noob here. Lets say I have a sheet.
. | A | B | C | D |
---|---|---|---|---|
1 | Adam | 3 | No | No |
2 | Betty | 13 | Yes | No |
3 | Chris | 12 | No | Yes |
4 | Dave | 0 | Yes | Yes |
5 | Emma | 1 | No |
I want to conditionally highlight cells in multiple ways:
- if column
C
and columnD
both contain the word 'Yes' colour the row green (e.g. match row 4) - if column
C
and columnD
are not the same, colour the row yellow (e.g. match rows 2,3) - if column
C
orD
are empty, colour the row red (e.g. match row 5)
I set up two worksheet conditional formatters
=AND(SEARCH("Yes",$C2)>0,SEARCH("Yes",$D2)>0)
is set to be green=$C2<>$D2
is set to be yellow=OR(ISBLANK($C2),ISBLANK($D2))
is set to be red
However, I'm getting mixed results. I get green rows where C and D are No or where C and D are different. I don't get any formatting for the second or third rules.
I tried just matching column values directly; =$C2="Yes"
doesn't match, hence resorting to SEARCH.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您观察到的行为是因为规则2和amp之间的共同点; 3,即,如果C2与D2不同,则在表面上是因为这些单元的含量有所不同,但是如果一个单元格为空白,而另一个单元格为空,则两种规则2&amp; 3同时满足。
在下面的屏幕截图中,我假设要在“非平等”行之前识别“半空白”行:

“均等”行的公式为
( countif()在较长的文本中找到是yes ,如果找不到的话,将返回0,该函数在and and()函数中被解释为false,而如果是,则将发现该函数将返回1,被解释为true),
鉴于您的规则2的非独立性&amp; 3重要的是要优先考虑实施规则,如屏幕截图所示,可以通过使用上下按钮(突出显示)将当前选择的规则上下移动。
Your observed behaviour is because of the commonality between rules 2 & 3, i.e. if C2 differs from D2 then it is, superficially, because the content of those cells differ but, if one of the cells is blank, when the other isn't, then both rules 2 & 3 are satisfied simultaneously.
In the screenshot below, I have made the assumption that 'half-blank' rows are to be identified before 'non-equal' rows:

the formula for 'equal' rows is
(COUNTIF() is used because it caters for Yes being found within a longer string of text and, if not found at all, will return 0, which is interpreted, inside the AND() function, as FALSE, whereas if Yes is found then the function will return 1, interpreted as TRUE)
Given the non-independence of your rules 2 & 3 it is important that the rules implemented are prioritised as illustrated in the screenshot, which can be achieved by using the up and down buttons (highlighted) to move the currently-selected rule either up or down.