vba 根据列中的值为完整的行着色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11280579/
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 13:26:08  来源:igfitidea点击:

Coloring complete Row based on values from Columns

excelvbaexcel-vbaexcel-formula

提问by user1494042

I need to color the complete Excel row based upon the value of a cell in column.

我需要根据列中单元格的值为完整的 Excel 行着色。

I have three columns (Item, Priceand Status) and want to color the row if the Statusvalue is:

我有三列(Item,PriceStatus),如果Status值为:

  • DELIVERED (to Green)
  • REJECTED (to Red)
  • WIP (to Orange).
  • 已交付(至绿色)
  • 拒绝(对红色)
  • WIP(到橙色)。

回答by brettdj

You can use (non-VBA) conditional formatting for this

您可以为此使用(非 VBA)条件格式

If your Status column was in column C then - having selected all the rows in the area of interest - you can use rules such as this to format the entire row based on the column C entries

如果您的状态列在 C 列中,那么 - 选择了感兴趣区域中的所有行 - 您可以使用这样的规则来根据 C 列条目格式化整行

=$C1="REJECTED"and pick Red
=$C1="WIP"and pick Orange etc

=$C1="REJECTED"并选择红色
=$C1="WIP"和橙色等

Change your column reference to suit

更改您的列引用以适应

The sample below is from Excel 2010

下面的示例来自 Excel 2010

{NB: Change your text case if necessary}

{注意:如有必要,请更改您的文本大小写}

See Debra Dalgleish's sitefor more detail

有关更多详细信息,请参阅Debra Dalgleish 的网站

enter image description here

在此处输入图片说明