简体   繁体   English

根据另一个单元格的值为单元格范围着色?

[英]Colour a cell range based on another cell's value?

I am trying to write a statement in MS Excel 2013 that does the following: 我正在尝试在MS Excel 2013中编写执行以下操作的语句:

If cell E3 = "N/A" , make the background colour of cell range F3:N3 = black If cell E3 = "N/A" ,则使单元格范围F3:N3 =黑色的背景色

If cell E3 = anything else , do nothing If cell E3 = anything else ,则不执行任何操作

Some sort of conditional formatting? 某种条件格式? I tried a few options but couldn't get it going? 我尝试了几种方法,但无法解决? :( :(

Any suggestions? 有什么建议么?

Select cells F3 to N3. 选择单元格F3到N3。 On the Home Ribbon click Conditional Formatting > New Rule > Use a formula to.... 在主功能区上,单击“条件格式”>“新规则”>“使用公式来...”。

Use this formula 使用这个公式

=isna($e3)

Note the placement of the $ sign. 注意$符号的位置。 Select the Format button and apply a format. 选择格式按钮并应用格式。 Confirm all dialogs. 确认所有对话框。

If you wish to do this with Excel VBA (as per your question tags), then you can use the Interior.Color property of a cell range: 如果希望使用Excel VBA(根据您的问题标签)执行此操作,则可以使用单元格区域的Interior.Color属性:

ActiveSheet.Range("F3:N3").Interior.Color = RGB(0,0,0)

If you need to clear the background if cell E3 is not "N/A" then use 如果单元格E3不是“ N / A”,则需要清除背景,请使用

ActiveSheet.Range("F3:N3").Interior.ColorIndex = 0

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

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