Hi , there. Can anyone help me. How do I add list of emails who can edit a google sheet. I can only add myself but not others. The script I'm using is below. Kindly help. Cheers. Ong
function protectRange() {
// Protect the active sheet except B2:C5, then remove all other users from the list of editors.
var sheet = SpreadsheetApp.getActiveSheet();
var protection = sheet.protect().setDescription('Protected sheet');
protection.setUnprotectedRanges([sheet.getRange('1:1'),sheet.getRange('A:A')]);
// Ensure the current user is an editor before removing others. Otherwise, if the user's edit
// permission comes from a group, the script throws an exception upon removing the group.
var me = Session.getEffectiveUser();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}