I am trying to write a script that will protect a varying range in sheets weekly. I have figured out the weekly locking and trigger to initiate it. However, Each week needs a new range. If week 1 was;
var range = sheet.getRange(4, 5, 5, 6);
week 2 would need;
var range = sheet.getRange(10, 5, 5, 6);
and so on. So only my Row input will need changing based off the week the trigger is actived.
Complete Script is currently as follows:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Multiple'); //INSERT SHEET NAME HERE
function lockRange(row, col){
var range = sheet.getRange(10, 5, 5, 6);
// Create protection object. Set description, anything you like.
var protection = range.protect().setDescription('Date1');
// Ensure the current user is an editor before removing others. Otherwise, if the user's edit
// permission comes from a group, the script will throw an exception upon removing the group.
var me = Session.getEffectiveUser();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}