I want to code my Google Sheets cells in a way that certain cells automatically lock at a specific time every day. I should be able to edit it, but not my collaborators.
How do I pull this off?
In the sample sheet (link here), you will see certain dates (15/7/2015-17/7/2015). I want to code it so that each date (eg A1:B6
) is locked daily, 10 pm.
As @NightShadeQueen suggested a combination of Time-driven triggers and the protect()-method of the Class Range can be used.
You'll have to modify the code if your sheet doesn't look like the Sample sheet. Especially the
lockRanges()
-function, which defines which ranges should be protected. Currently, it starts with cellA1
, and steps down 7 rows at a time until the end of the sheet is reached.Run
=lockRanges
Events
=Time-driven
,Day timer
,10pm to 11pm
(or whenever you want)That's it, now the ranges will be protected at the time you chose. As with ranges you protect manually, they show up in Data > Protected sheets and ranges.
Something unclear? Ask away!