Here's the code I've got. It's not working and I'm not sure why!I want this script to run only on the tab/sheet called Trading Journal. Currently nothing happens when I include the if statement.
function onEdit(e) {
var cell = e.range;
var sh = e.source.getActiveSheet();
if(sh.getName() === "Trading Journal") {
// set active cell colour
cell.setBackground('#fff');
cell.setFontSize(10) // Sets size to 10 (has to be a number)
cell.setFontFamily() // Resets font family
}
}
Thanks ahead of time for the help.
CodePudding user response:
This will execute on any edit on sheet Trading Journal
function onEdit(e) {
const sh = e.range.getSheet();
if (sh.getName() == 'Trading Journal') {
e.range.setBackground('#ffffff');
e.range.setFontSize(10);
e.range.setFontFamily("Arial");
})
}
CodePudding user response:
I'm sure it because there is no such color #fff.
Try to change the color. For example like this:
cell.setBackground('#fff000');
If you mean a white color it should be #ffffff.
And if you want to reset the font family I'd propose to add undefined inside the brackets this way:
cell.setFontFamily(undefined);
