0
votes

I want to code my Google Sheets cells in a way that certain cells automatically lock at a specific time in another cell. I should be able to edit it, but not my collaborators.

How do I pull this off?

File sample link

In the sample sheet 1, If row cell D:D > 120 then cell row E protect. example: on file C 9 > 120 then E 9 protected.

1

1 Answers

0
votes

Based from this forum, you would need all the email address of your collaborators if you are trying to restrict others from editing their own input or if you want them blocked from editing your own. But then this script would also be locking their input into a cell after they do.

function onEdit(e) { 
 var active =  SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet Name").getActiveCell();
 active.protect().removeEditor("other editors emails");
  if(active.getColumn() == 5) { // condition for column active 
     active.setNote("Locked");
   }
  }

Note:

getSheetByName("Sheet Name") - would be to limit this function to that sheet. active.setNote("Locked"); - to display which cells are locked.