0

I have the data of 300*8 cell in that 3rd row contains email on based of that i m protecting row by appscript. I m new to appscript and no background of coding or computer.

I have made the formula and normally running in individual row No but if I adding in to for loop it is not getting work

  var ss = SpreadsheetApp.getActive();
  
  var master = ss.getSheetByName("Master sheet");//in this sheet data present

  ss.setActiveSheet(master, true);
 
  for(i=0;i=10;i ++ ); {
  var range  = master.getRange(i+5,3).getValue();
  var protection = master.getRange(i+5,1,1,6).protect();
  var remove = protection.getEditors();
       protection.setDescription(range).removeEditors(remove).addEditor(range);
}
}

If I put value instead of loop var i at row value then it work properly

aynber
  • 22,380
  • 8
  • 50
  • 63
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Feb 04 '22 at 01:22

1 Answers1

0

Try This:

function myfunk() {
  const ss = SpreadsheetApp.getActive();
  const master = ss.getSheetByName("Master sheet");

  for (let i = 0; i <= 10; i++) {
    var value = master.getRange(i + 5, 3).getValue();
    var protection = master.getRange(i + 5, 1, 1, 6).protect();
    var remove = protection.getEditors();
    protection.setDescription(value).removeEditors(remove).addEditor(value);
  }
}
Cooper
  • 59,616
  • 6
  • 23
  • 54