Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

How to protect a range in Google sheet using a macro from Google Apps script?

$
0
0

I recorded a macro using the traditional way (GUI) to protect a range. The following script was generated.

function protect() {  var spreadsheet = SpreadsheetApp.getActive();  spreadsheet.getRange('C:C').activate();  var protection = spreadsheet.getRange('C:C').protect();  protection.setDescription('test');};

However, when I apply that macro on other sheets, anybody (say user X) can edit the range. When I check for the protected range, it shows that the owner and user X are permitted to edit. This shouldn't happen.

However, when I manually set permissions then everything works fine.

How to solve this?


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>