I am trying to create a script to protect my formulas in sheets that co-workers will use. I have 10 workbooks with 26 sheets each, all are virtually identical as far as the the locations of the protected and unprotected ranges.
As far as I can tell the best way to do this is to protect the whole sheet then unprotect certain cells for data entry.
This is the script I have so far, I've cut out about 90% of the ranges I need unprotected to make it smaller.
function ProtectRanges() {
var sheet = SpreadsheetApp.getActiveSheet();
var protection = sheet.protect().setDescription("Protect Formulas");
var unprotected = sheet.getRange("S6:AF51")
sheet.getRange("S66:AF66")
sheet.getRange("S70:AF70")
sheet.getRange("S72:AF72")
var me = Session.getEffectiveUser();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}
The problem I'm having is that the people that I share this with can't edit any of the cells, protected or not. I need to be the only one who can edit the formulas, but the data entry cells need to be open for them to edit.