数据:
- B1: =GoogleClock//此函数实时显示小时。 2013年11月28日15:45:00
- C3: 0:15:00//时间(以小时为单位)
- E3:2013年11月28日15:45:00
- F3: =SUM(E3+C3)//结果为 28/11/2013 16:00:00
- G3: =IF(C3>0;IF($B$1>=$F3;"调用";"及时");"")
公式将检查 B1 >= F3 是否,如果未及时,结果将调用。
正如您在此示例中看到的,现在是 15:45,G3 将显示“In Time”,但当 =googleclock 函数标记 28/11/2013 16:00:00 时,G3 会将值更改为 Call。在那一刻背景应该从绿色变为红色-
情况:
I have a formula in the Column G, the result of that formula "Call" or "In Time".
I set a conditional formatting using Menu > Format > Conditional Formatting to Column G. but the conditional only work for the existing rows.
问题:
If I add new rows the Conditional Formatting is not set to that news rows.
解决方案是创建一个脚本来检测单元格中的值,如果“值”是“调用”,则将背景颜色设置为红色,如果“及时”,则将背景颜色设置为绿色。
如果我将此脚本设置为在 OnEdit 中运行或每 5 分钟或每分钟运行一次,系统会变慢,因为此脚本每次都会检查该值。
是否有任何方法可以像我从菜单中设置的那样设置条件格式?
最佳答案
Range.copyTo()可以复制条件格式。
例如,此代码段会将条件格式从单元格 A1
复制到该列的其余部分:
function copyFormat() {
var source = ss.getRange('A1');
var destination = ss.getRange('A2:A');
source.copyTo(destination, {formatOnly:true});
}
关于google-apps-script - 谷歌脚本: How to implement conditional formatting into spreadsheet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20273493/