I found the onEdit script below for only one checkbox being ticked at a time and uncheck all others, when a new checkbox is ticked. Unfortunately I don´t know how to modify this script for a cell range A5:A1000. For two cells it works fine in the A1 notation ['A13','B13'], but ['A5:A1000'] doesn´t work. Any ideas? Thanks a lot!
function onEdit(e) {
const as = e.source.getActiveSheet();
const cell = e.range.getA1Notation();
const cell_checks = ['A13','B13'];
if(as.getName() == "Sheet1" && cell_checks.includes(cell) && e.range.isChecked())
{cell_checks.filter(val=>val!=cell).forEach(c=>as.getRange(c).uncheck())}
}
CodePudding user response:
Try this:
function onEdit(e) {
//e.source.toast("Entry")
const sh = e.range.getSheet();
const cell = e.range.getA1Notation();
if (sh.getName() == "Sheet1" && e.range.columnStart == 1 && e.range.rowStart > 4 && e.value == "TRUE") {
//e.source.toast("GATE1")
let o = sh.getRange(5, 1, 996).getValues().flat().map((v, i) => {
if (i 5 != e.range.rowStart) {
return ["FALSE"];
} else {
return ["TRUE"];
}
});
sh.getRange(5, 1, o.length).setValues(o);
}
}