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.
![](https://i0.wp.com/bloggerinyou.com/wp-content/uploads/2023/02/image-1.png?resize=390%2C718&ssl=1)
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
![How to prevent adding of new sheets in google sheet- Trigger settings](https://i0.wp.com/bloggerinyou.com/wp-content/uploads/2023/02/How-to-prevent-adding-of-new-sheets-in-google-sheet-Trigger-settings.png?resize=501%2C480&ssl=1)
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; }
![](https://i0.wp.com/bloggerinyou.com/wp-content/uploads/2023/02/image.png?w=840&ssl=1)
![](https://i0.wp.com/bloggerinyou.com/wp-content/uploads/2023/02/image-1.png?resize=390%2C718&ssl=1)
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
![How to prevent adding of new sheets in google sheet- Trigger settings](https://i0.wp.com/bloggerinyou.com/wp-content/uploads/2023/02/How-to-prevent-adding-of-new-sheets-in-google-sheet-Trigger-settings.png?resize=501%2C480&ssl=1)
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; }