'I want to lock my cell cells (E3:AH17) daily after 11:00 am base on cell date

[how to lock cell autometicly base on cell data & and time everyday?]https://docs.google.com/spreadsheets/d/1PQTpr9tes5_7c963nV_c0BSOdemYD6Vpyd1SB1elANE/edit#gid=1118459963



Solution 1:[1]

A possible solution for this is to use a time based trigger in Apps Script which will lock the cells you want.

You should start by writing a script similar to this:

function lockCells() {
  let sheet = SpreadsheetApp.openById("SS_ID").getSheetByName("Attendance1");
  let protection = sheet.getRange(3, 5, 15, 30).protect(); // CORRESPONDS TO E3:AH17
  let editors = protection.getEditors();
  protection.removeEditors(editors)
}

function timeTrigger() {
  ScriptApp.newTrigger('lockCells')
    .timeBased()
    .atHour(11)
    .create();
}

The code above consists in the two functions:

  • lockCells - which is used to protect the range by retrieving the editors and then removing them;

  • timeTrigger - which will trigger the lockCells function every day at 11:00.

Reference

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ale13