Search code examples
google-sheetsgoogle-apps-scriptspreadsheet-protection

Is there any way to use apps script to add an exception to a sheet protection?


I'm making this city thing in google sheets, and I want to be able to add an exception to a sheet protection(see what I mean here). Is there any way to do this programmatically with apps script?

I tried getting the sheet protection and calling .setRange on it, but that didn't work. I also couldn't find anything about this in the apps script documentation.


Solution

  • You can use setUnprotectedRanges(ranges) (documentation) to set the ranges that can be edited on otherwise protected sheet.