Google Spreadsheet条件格式化脚本 [英] Google Spreadsheet conditional formatting script
本文介绍了Google Spreadsheet条件格式化脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图弄清楚如何在谷歌电子表格上使用条件格式,类似于你可以在Excel中通过公式做的事情。
I am trying to figure out how to use conditional formatting on a google spreadsheet similar to what you can do in excel via a formula.
我希望单元格A2到如果单元格O2的值为X,则更改为绿色,并且这将在两列完成。我知道这将需要一个脚本。
I want cell A2 to change to Green if cell O2 has a value of "X" and this will be done on both columns all the way down. I know this will require a script.
我遇到了一个类似的链接,但我不知道如何调整它以满足我的需求。这是可以做的吗?
I ran across a link that is similar but i do not know how to adjust it to meet my needs. Is this something that can be done?
链接: https://webapps.stackexchange.com/questions/16745/google-spreadsheets-conditional-formatting
推荐答案
function formatting() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
var columnO = sheet.getRange(2, 15, sheet.getLastRow()-1, 1);
var oValues = columnO.getValues();
for (var i = 0; i < oValues.length; i++) {
if (oValues[i][0] == 'X') {
sheet.getRange(i + 2, 1, 1, 1).setBackgroundColor('green');
}
}
}
这篇关于Google Spreadsheet条件格式化脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文