So I am looking for a script where I can define 2 cells with checkboxes in where one check box can only be checked at a time
I need the script to be able for me to add and remove pairs of checkbox's when I need to
so in the script I can copy and past a line to add another pair and then define the cells with lets say A8,D9 and these would toggle true and false
but be able to remove this line if I remove or changing their location
here is my test sheet if you can help
https://docs.google.com/spreadsheets/d/1YWfloYTN1PLjohvIGS0UMGQrR2lnZQCNiIN0_Na1ijM/edit#gid=0
Updated image to try show what i need
just remember these locations may change so i need to update, add or remove the cell locations
I do thank you for your help in advance
CodePudding user response:
I got it to work
here is the answer
function onEdit(e) {
let ss = SpreadsheetApp.getActiveSpreadsheet();
let sheet = ss.getSheetByName('Radio Button Example');
let range = e.range
let col = range.columnStart;
let row = range.rowStart;
let yes = col == 2 && row == 5;
let no = col == 3 && row == 5;
if(yes && sheet.getRange(row,col).isChecked()){
sheet.getRange(5,3).uncheck();
}
if(no && sheet.getRange(row,col).isChecked()){
sheet.getRange(5,2).uncheck();
}
let yes1 = col == 5 && row == 11;
let no1 = col == 8 && row == 5;
if(yes1 && sheet.getRange(row,col).isChecked()){
sheet.getRange(5,8).uncheck();
}
if(no1 && sheet.getRange(row,col).isChecked()){
sheet.getRange(11,5).uncheck();
}
}