Reputation: 70
Trying to get my script to use a named range. In that range I am trying to reset the cell colors back to white. I keep getting an object error, can't figure out how to make this work.
function resetCheckDirectory() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var tableRange = ss.getRangeByName("rangename");
tableRange.setBackgrounds("#FFF");
};
Upvotes: 2
Views: 5934
Reputation: 46802
You are making a simple spelling error, setBackground
in this case is without s
because you are setting a single color to multiple cells (the argument is "#FFF")
So the code is :
function resetCheckDirectory() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var tableRange = ss.getRangeByName("NamedRange1");
tableRange.setBackground("#FFF");
};
to summarize :
setBackground
is used with single string argument and applies to single cell or any range where all colors are identicalsetBackgrounds
is used with a 2 dimensions array as argument and applies to a range where you need to set different colors in different cells.Upvotes: 3