I've recently started using google scripts for google sheets and I can't get my onEdit function to work this is my code:
function onEdit(event) {
var range = event.range;
var spreadsheet = event.source;
var r = event.source.getActiveRange();
var activesheet = spreadsheet.getActiveSheet();
var column = range.getColumn();
var row = range.getRow();
var spreadsheetname = activesheet.getName();
var D5LOC = activesheet.getRange("D5").getValue();
activesheet.getRange("D3").setValue(D5LOC);
if(D5LOC == "FALSE"){
activesheet.getRange("D6").setValue(activesheet.getRange("D5").getValue());
if (!(column == 1)&&!(column == 2)&&event.value == "FALSE")
{
activesheet.getRange("D6").setValue(activesheet.getRange("D5").getValue());
r.setValue("TRUE");
}
}
}
It's supposed to check every box that I've unchecked whenever a confirmation box is unchecked, however when I uncheck something it just doesn't do anything. please help
As far as I can tell this seems to be what your code currently boils down to:
function onEdit(e) {
const sh = e.range.getSheet();
const D5LOC = sh.getRange("D5").getValue();
if (sh.getName() == 'Sheet1' && e.range.columnStart > 2 && D5LOC == "FALSE" && e.value == "FALSE") {
sh.getRange("D3").setValue(D5LOC);
sh.getRange("D6").setValue(D5LOC);
e.range.setValue("TRUE")
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.