如何根据Google表格上单元格的颜色更新单元格?

时间:2020-05-09 05:34:49

标签: function google-sheets colors format cell

如果该单元格具有特定的颜色,那么我希望它在单独的单元格中输出值。

不太确定如何定义cellcolor /类似功能。

例如:

=IF(CELLcolour(K2)=22,"Y","N")

1 个答案:

答案 0 :(得分:1)

您可以使用脚本来完成。转到工具>脚本编辑器,然后使用以下代码:

function getCellColor(x) { var formula = SpreadsheetApp.getActiveRange().getFormula(); formula = formula.substring(formula.indexOf("(")+1, formula.indexOf(")")); color = SpreadsheetApp.getActiveRange().getSheet().getRange(formula).getBackground(); return color; }

然后您可以使用公式获取单元格的背景色 =getCellColor(A1)在您的Google表格中。这仅适用于单元格,而不适用于范围。