Good day.
In appscript I made a code in which if a checkbox in cell C5 is true, then creates some words in the range C12:N41. That part of the code works perfectly, but what I want to do is to protect that range once all the words are created so noone can edit them. I added that code but it’s not working. My code of the protection part is:
function createTable() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
tablaData = [
[One,Two,Three,Four,Five,Six,false,Eight,Nine,Ten,false,Twelve],
[One,Two,Three,Four,Five,Six,false,Eight,Nine,Ten,false,Twelve],
[One,Two,Three,Four,Five,Six,false,Eight,Nine,Ten,false,Twelve],
[One,Two,Three,Four,Five,Six,false,Eight,Nine,Ten,false,Twelve],
[One,Two,Three,Four,Five,Six,false,Eight,Nine,Ten,false,Twelve],
[One,Two,Three,Four,Five,Six,false,Eight,Nine,Ten,false,Twelve]
];
var startCell = sheet.getRange('C12');
for (var i = 0; i < tablaData.length; i++) {
startCell.offset(i, 0, 1, tablaData[i].length).setValues([tablaData[i]]);
for (var j = 0; j < tablaData[i].length; j++) {
if (tablaData[i][j] === false) {
startCell.offset(i, j).insertCheckboxes();
}
}
}
var protection = sheet.getRange('C12:N41').protect();
protection.setDescription('Protection of C12:N41');
}