简体   繁体   English

根据单元格值突出显示整行

[英]Highlighting the entire row based on cell value

I want the entire row to be highlighted Yellow when the Cell I1, I2, I3 etc.. is 1 当单元格I1,I2,I3等为1时,我希望将整行突出显示为黄色

or 要么

the entire row to be highlighted Green when the Cell I1, I2, I3 is 0 当单元格I1,I2,I3为0时,要突出显示的整个行为绿色

anyone can help with the VBA coding, what should the VBA coding be? 任何人都可以帮助VBA编码,那么VBA编码应该是什么?

在此处输入图片说明

You can do this without VBA with Conditional Formats. 您可以在不使用带有条件格式的VBA的情况下执行此操作。

E. g.: Mark entire Rows from 1:10 (just an example). 例如:从1:10标记整个行(仅作为示例)。

Set up the conditional format to 设置条件格式为
=$I1=1
and set the background color for this format. 并设置此格式的背景色。
This will instantly work on all rows 1 to 10 in column I. 这将立即在I列的所有1至10行中起作用。
(you need to add a rule for each value/color). (您需要为每个值/颜色添加一个规则)。

EDIT: 编辑:
Conditional Formats can be copied/applied through VBA as well. 条件格式也可以通过VBA复制/应用。 The disadvantage of VBA firing on every cell change is that it kills the undo function, and you have to be careful with multicell and multiarea inserts/copies etc. 每次更改单元格时VBA触发的缺点是,它会取消撤消功能,因此您在使用多单元格和多区域插入/副本时必须格外小心。

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

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