vba 使用条件格式根据另一个工作表中的 3 个值将单元格变为红色、黄色或绿色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19361415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 16:54:00  来源:igfitidea点击:

Use Conditional formatting to turn a cell Red, yellow or green depending on 3 values in another sheet

excelexcel-vbavba

提问by user2878987

I have a table with 262 rows and 52 columns of data(numbers). I want to set each one of the cells to a RAG(Red,Amber,Green) format(Conditional maybe). The cell needs to reference another sheet(new sheet) with 3 columns(A,B,C) and 262 rows. The formula for the 3 RAG values needs to look like:-

我有一个包含 262 行和 52 列数据(数字)的表格。我想将每个单元格设置为 RAG(红色、琥珀色、绿色)格式(可能有条件)。单元格需要引用另一个有 3 列(A、B、C)和 262 行的工作表(新工作表)。3 个 RAG 值的公式需要如下所示:-

if the value A100 <= column A,B,C100(new sheet) then turn cell Green if the value A100 = or 10% greater than column A,B,C100(new sheet) then turn cell Amber if the value A100 = or 20% greater than column A,B,C100(new sheet) then turn cell Red

如果值 A100 <= 列 A、B、C100(新表),则如果值 A100 = 或比列 A、B、C100(新表)大 10%,则将单元格变为绿色,如果值 A100 = 或,则将单元格变为琥珀色比 A、B、C100 列(新工作表)大 20%,然后将单元格变为红色

回答by Joe Laviano

  1. Highlight the range in question.
  2. On the Home tab, in the Styles Group, Click "Conditional Formatting".
  3. Click "Highlight cell rules"
  1. 突出显示有问题的范围。
  2. 在“开始”选项卡上的“样式组”中,单击“条件格式”。
  3. 点击“突出显示单元格规则”

For the first rule,

对于第一条规则,

Click "greater than", then in the value option box, click on the cell criteria you want it to be less than, than use the format drop-down to select your color.

单击“大于”,然后在值选项框中,单击您希望它小于的单元格条件,然后使用格式下拉菜单选择您的颜色。

For the second,

对于第二个,

Click "less than", then in the value option box, type "=.9*" and then click the cell criteria, then use the formatting just like step 1.

单击“小于”,然后在值选项框中键入“=.9*”,然后单击单元格条件,然后使用与步骤 1 一样的格式。

For the third,

对于第三个,

Same as the second, except your formula is =".8*" rather than .9.

与第二个相同,除了您的公式是 =".8*" 而不是 .9。