Protect the Same Ranges of Every Tab

How to protect the same asynchronous ranges on every tab on a Sheet.
Important notes:
* The ranges in an array of A1 notation Strings of the ranges. Make sure the quotation marks are around them
* Don’t mix up the variables for each FOR() loop

Sheet (to copy from “Make a copy” in File)

function protectRanges(){
const sh = SpreadsheetApp.getActive();
let ranges = [“A1:F5″,”I1:K1″,”I3:K3″,”I5:K5”];
let sheets = sh.getSheets();
let ss, p;
for (let i in sheets){
ss = sheets[i];
for (let j in ranges){
p = ss.getRange(ranges[j]).protect();
if (p.canDomainEdit()){

Connect with me:
• Twitter @FarrisSpencer
• Google Product Expert

Leave a Reply

Your email address will not be published. Required fields are marked *