我试图用另一个单元格的十六进制值更改单元格的背景颜色。例如,我想使A2中的单元格具有#333333的背景色(这是单元格A1的文本值)。这是我到目前为止的代码:
function setColor(targetCell) {
// get targetCell's value (a hex value)
// set the background of the active cell to the value of targetCell
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var value = ss.getRange(targetCell).getValue();
var cell = sheet.getActiveCell().setBackground(value);
return cell;
};
现在,由于getRange(targetCell)不正确,该代码将无法运行,但是即使我将targetCell替换为“ A1”之类的内容,也会收到错误消息“您无权调用setBackground(第9行)”
简而言之,自定义函数无法修改其他单元格,
请参阅有关自定义功能的文档以了解其限制。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句