简体   繁体   English

基于表的值的条件格式

[英]Conditional Formatting based on values of table

I would like to turn black a cell if on the table any of the rows match this condition: 如果表格中的任何行符合此条件,我想将单元格变黑:

Table : A1:G100 桌子:A1:G100
Cell to format J1 单元格格式化J1

Condition that I would like to to implement: 我要实施的条件:

IF(AND(A1=0;OR(B1="bob";B1="jack")) 

turn the cell J1 black. 将单元格J1变黑。

例

I used the Excel conditional formatting function and I got the result applying the formula only to the first row of my table. 我使用了Excel条件格式函数,并且将公式仅应用到表的第一行就得到了结果。 How can I format the cell based on the repetition of the formula for each column of the table? 如何根据表格每列的公式重复来设置单元格的格式?

Suggest a custom formula for J1 of 建议为J1的自定义公式

=COUNTIFS(A:A,0,B:B,"bob")+COUNTIFS(A:A,0,B:B,"jack")

and choose black fill colour. 并选择黑色填充颜色。

There is no need to add IF, the condition is already an IF: 无需添加IF,条件已经是IF:

add ,A2=0 at the back only if you want to color Number 0 (column A) as well - just change the color to J1 in conditional formatting fill format 仅当您也要给数字0(A列)上色时,才在后面添加A2 = 0-只需按条件格式填充格式将颜色更改为J1

=OR(AND($A2=0,OR(A2="jack",A2="bob")),A2=0)

在此处输入图片说明

It's an intense formula but if you are looking for an one formula answer strictly for the conditional formatting formula and impacting nothing else, try the following. 这是一个激烈的公式,但是如果您要寻找一个仅针对条件格式公式的公式答案,而对其他格式没有任何影响,请尝试以下方法。 your formula in the conditional formatting formula should be 您的条件格式公式中的公式应为

=SUMPRODUCT((A:A=0)*(B:B="jack"))+SUMPRODUCT((A:A=0)*(B:B="bob"))>0

The reason for the two separate sumproduct formulas is to capture "jack" and "bob" instances as an inclusive OR which is triggered by the sum of the two being greater than zero (at least 1 instance of "0 and jack" OR "0 and bob" must be true). 两个单独的sumproduct公式的原因是将“ jack”和“ bob”实例捕获为包含性OR,这是由二者之和大于零触发的(至少1个实例为“ 0 and jack”或“ 0”和鲍勃”必须为真)。

Please use this answer ONLY if you have a special purpose for your J1 cell and you cannot afford a logic block (usually on a separate sheet) to colour your cell. 仅当您对J1电池有特殊用途并且无法负担逻辑块(通常在单独的纸上)为电池着色时,请使用此答案。 Otherwise please refer to @Tom Sharpe's answer. 否则,请参阅@Tom Sharpe的答案。 His formula could be contained anywhere and the conditional formatting simply look if that cell is greater than 0. 他的公式可以包含在任何位置,条件格式可以简单地查看该单元格是否大于0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM