I am currently working on a Google sheet which I have to share with other users for editing. But I want that after any user enters data in any cell of column C, the cell gets locked and user can not edit cell but just the owner of the sheet. I reckon that this would be done by Google Apps Script. Below script would do what I want but for whole sheet. I want it to apply it on just Column C. Any help would be appreciated.
0
votes
1 Answers
0
votes
Thank you for the feedback, I have been able to modify code according to my requirements. Here is the updated version of this Code if you want to apply validation on just one column but not the whole sheet:
function protectOnEdit(event) {
var range = event.range;
var Col= parseInt(range.getColumn());
console.log(Col);
if(Col==3)
{
var timeZone = Session.getScriptTimeZone();
var stringDate = Utilities.formatDate(new Date(), timeZone, 'dd/MM/yy HH:mm');
var description = 'Protected on ' + stringDate;
var protection = range.protect().setDescription(description);
var me = Session.getEffectiveUser();
//user who installed trigger
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}
}