0
votes

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.

[Link] Autolock Google Sheets cells after the first entry

1
Hi there @Roomi ! I understand that you took the linked example code, modified it and applied to reach your goal of applying it on just Column C. Please, share your findings with us so we all can take a look at it.Jacques-Guzel Heron

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);
  }
}

}