Use Checkboxes as Radio Buttons with a FOR() loop

Using a FOR() loop to make checkboxes behave as radio buttons.
Important notes:
DO NOT run the script manually, it will fail.
Make sure the array indexes and the Sheet rows match with some math.

Sheet (to copy – go to File, Make a copy)
https://docs.google.com/spreadsheets/…

Script:
function onEdit(e){
if (e.range.columnStart != 2 || e.range.rowStart == 1 || e.range.rowStart ‘greater_than_sign’ 8 || e.value != “TRUE”) return;
let r = SpreadsheetApp.getActive().getActiveSheet().getRange(2,2,7);
let checks = r.getValues();
for (let i in checks){
if (checks[i][0] == true && +i != e.range.rowStart – 2)
checks[i][0] = false;
}
r.setValues(checks);
}

Connect with me:
• spencer.farris@gmail.com
• spencerfarris.me
• www.linkedin.com/in/spencer-farris/
• Twitter @FarrisSpencer
• Google Product Expert support.google.com/docs/profile/12305

Leave a Reply

Your email address will not be published. Required fields are marked *