I had created a calculator on Google Sheet
And I was looking for ways to prevent my users from editing certain cells
This I could easily achieve by going to the Data menu and selecting the Protect sheets and ranges option as mentioned below.
Next I was wondering how can I look at protecting the user for adding new sheets for which I found this simple app script very useful
Trigger Type Used
function myFunction() { //Testing var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheets = ss.getSheets(); var sheets_name= ""; for(i in sheets){ var sheetName = sheets[i].getName(); if(sheetName . indexOf("Sheet") > -1 || sheetName.indexOf("Copy of") > -1){ sheets_name = sheets_name + " "+ sheetName; ss.deleteSheet(sheets[i]); } } return sheets_name; }
Thereafter, Add the cell range to be protected
Next I was wondering how can I look at protecting the user for adding new sheets for which I found this simple app script very useful
Trigger Type Used
function myFunction() { //Testing var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheets = ss.getSheets(); var sheets_name= ""; for(i in sheets){ var sheetName = sheets[i].getName(); if(sheetName . indexOf("Sheet") > -1 || sheetName.indexOf("Copy of") > -1){ sheets_name = sheets_name + " "+ sheetName; ss.deleteSheet(sheets[i]); } } return sheets_name; }