Explanation / Issue:
As per the official documentation, this is the correct way to apply a protection to the sheet.
The issue is that you didn't remove the list of editors from the protection
object. What you did instead was to remove them from the spreadsheet file itself.
Essentially, when you add a protection to a sheet, all the current editors automatically have the right to edit the sheet (or sheet range) regardless of the protection. So your script needs to remove them from that right, this is why we execute this:
protection.removeEditors(protection.getEditors());
Protect only the range F11:F14
of the sheet:
function myFunction() {
var sheetToProtect = SpreadsheetApp.getActive().getSheetByName('CheckList');
var range = sheetToProtect.getRange('F11:F14');
var protection = range.protect();
var me = Session.getEffectiveUser();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}
Protect the full range of the sheet except for F11:F14
:
function myFunction() {
var sheetToProtect = SpreadsheetApp.getActive().getSheetByName('CheckList');
var protection = sheetToProtect.protect();
var rngMonitorUnprotect = sheetToProtect.getRange("F11:F14");
protection.setUnprotectedRanges([rngMonitorUnprotect]);
var me = Session.getEffectiveUser();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}