Click here to Skip to main content
14,356,442 members
Rate this:
Please Sign up or sign in to vote.
I have a table in Google Sheets in the format:

A B C

Date supply demand

Date2 supply demand

etc.

Others are required to fill in inventory and demand every day. However, they should only fill out demand and inventory of the current day. They are also not allowed to change previous data or in advance fill in future days inventory and demand. Therefore, I want to protect the whole sheet from being edited by others, except the row with the current date. For example today (23.09) they should be able to edit the row where B is 23.09.2019 and nothing else. 

This works perfectly find on desktop. I will post my current code below. However, I do not know how to get the code running in the iOS and Android Google Sheets App, because some survey participants will use mobile instead of desktop. Here is my current sheet: https://docs.google.com/spreadsheets/d/17zcMDIz97VjEeN6WgBKR2ZppWz88cePtljxr5-68vQg/edit?usp=sharing

What I have tried:

My current code in the script editor: 

only be able to edit current date

function myFunction() {
 var sheet=SpreadsheetApp.getActive().getActiveSheet();
 var range=sheet.getDataRange();
 var values=range.getValues();
 var today=new Date();
 today.setHours(0);
 today.setMinutes(0);
 today.setSeconds(0);
 today.setMilliseconds(0);
 var todayMs=today.getTime();
  for(var i=5;i
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100