changing an onEdit function to run onOpen
I have the function below (taken online and adapted and works) that is an
on edit function, but... i want it to run/trigger when an import is done
OR on open, as the data will not really be edited it will just be
frequently overwritten by an import. Is this possible. Basically col A
values need to be formatted red depending on the values in a number of
other cols, only problem is im not editing it.
function onEdit(e) {
if (e) {
var ss = e.source.getActiveSheet();
var r = e.source.getActiveRange();
// If you want to be specific
// do not work in first row
// do not work in other sheets except "MySheet"
if (r.getRow() != 1 && ss.getName() == "e404") {
// E.g. status column is 2nd (B)
vm = ss.getRange(r.getRow(), 4).getValue();
gg = ss.getRange(r.getRow(), 5).getValue();
inter = ss.getRange(r.getRow(), 6).getValue();
other = ss.getRange(r.getRow(), 7).getValue();
// Specify the range with which You want to highlight
// with some reading of API you can easily modify the range
selection properties
// (e.g. to automatically select all columns)
rowRange = ss.getRange(r.getRow(),1,1,1);
// This changes font color
if (vm == '0' && gg == '0' && inter == '0' && other == '0') {
rowRange.setBackgroundColor("red");
} else {
rowRange.setBackgroundColor("white");
}
}
}
}
Wednesday, August 14, 2013
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment