Excel-对单元格进行编程以根据另一个单元格更改颜色 [英] Excel - programm cells to change colour based on another cell
本文介绍了Excel-对单元格进行编程以根据另一个单元格更改颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试为Excel创建公式,从而使一个单元格根据上一个单元格中的文本更改颜色。
I am trying to create a formula for Excel whereby a cell would change colour based on the text in the previous cell.
例如,如果单元格B2包含字母X,然后B3为Y,我希望B3变为绿色。
同样,如果B2包含X并且B3包含WI则希望B3变为红色。
So for example if cell B2 contains the letter X and then B3 is Y, I would like B3 to turn green.
Equally, if B2 contains X and B3 contains W I would like B3 to turn red.
非常感谢任何想法!
推荐答案
- 选择单元格B3,然后单击功能区中的条件格式按钮,然后选择新建规则 。
- 选择使用公式来确定要格式化的单元格
- 输入公式:
= IF(B2 = X,IF(B3 = Y,TRUE,FALSE),FALSE)
,然后选择填充绿色(如果是) - 创建另一个规则并输入公式
= IF(B2 = X,IF(B3 = W,TRUE,FALSE),FALSE)
,然后选择填充红色
- Select cell B3 and click the Conditional Formatting button in the ribbon and choose "New Rule".
- Select "Use a formula to determine which cells to format"
- Enter the formula:
=IF(B2="X",IF(B3="Y", TRUE, FALSE),FALSE)
, and choose to fill green when this is true - Create another rule and enter the formula
=IF(B2="X",IF(B3="W", TRUE, FALSE),FALSE)
and choose to fill red when this is true.
更多详细信息-使用公式的条件格式将在公式的值为TRUE时应用格式。您可以使用复合 IF
公式根据任何单元格的值返回true或false。
More details - conditional formatting with a formula applies the format when the formula evaluates to TRUE. You can use a compound IF
formula to return true or false based on the values of any cells.
这篇关于Excel-对单元格进行编程以根据另一个单元格更改颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文