How can I use 'i' to loop through the sheet index numbers?
I tried this:
function myFunction() {
for (var i = 2; i < 14; i );{
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getSheets()[i].getRange('J10').setFormula('=iferror(VLOOKUP($B9,\'STUDENT SCORES\'!AL46:AM49,2,FALSE)," ")');
}
}
But it does not work.
Thanks for the help!
CodePudding user response:
Use this sample script:-
function myFunction() {
var spreadsheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
for (var i = 2; i < spreadsheets.length; i );{
spreadsheets[i].getRange('J10')
.setFormula('=iferror(VLOOKUP($B9,\'STUDENT SCORES\'!AL46:AM49,2,FALSE)," ")');
}
}