I am trying to call a function when someone check a checkbox. I came up with this so far but it is not working. Checkboxes are in cells F2 and F3
function onEdit(e) {
var range = e.range
if(range.getCell() == "F2") {
resetData()
}
else if(range.getCell() == "F3") {
renameSheet()
}
}
It has many ways to do this. The basic one is
function onEdit() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
if (sheet.getRange("F2").isChecked()) {
resetData()
} else if (sheet.getRange("F3").isChecked()) {
renameSheet()
}
}
Addition with uncheck after the click
function onEdit() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
var range = sheet.getActiveRange()
if (range.isChecked()) {
if (range.getA1Notation() == "F2") {
resetData()
} else if (range.getA1Notation() == "F3") {
renameSheet()
}
range.uncheck()
}
}
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.