How can I use a For loop to loop tabs on sheet index numbers in Google Apps Script?

Andrew

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!

vector

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)," ")');     
  }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Can I use Google Apps Script to replace text across multiple tabs in a Google Sheet?

Google sheet + Apps script: faster then for loop

How can I use loop index in an attribute?

How to use partial matching in if loop in google apps script

Can I use Google Apps Script to make a Google Form display randomized text from a Google Sheet?

How to make a loop script for Google sheet?

Use A For Loop to Run Apps Script - Google Sheets / Apps Script

How Can I Print Values and Index Numbers of an ArrayList without a Loop?

How to stop foreach loop in Google apps script

Using Google Apps Script, how can I replace text in a Google Sheets template to make a new Sheet?

Using Apps Script, how can I display a google doc checklist from information in a google sheet?

How can I use dynamic variable numbers in a loop?

how can I force Google App Script MailApp.sendEmail to use a new thread for each email in a loop?

Google Apps Script Sheet extract numbers as string

How can I get this to protect a sheet on scripting basis (Google Apps Script)?

How can I fix the range of a Google Sheet MATCH function when using a move rows apps script?

How can I move urls from sheet ranges while building the links at destinations using Google Apps Script?

How can I redirect back to my website after google apps script sheet submission?

How can i get index use forEach loop?

How can I use an array index as form name in foreach loop?

How can I filter multiple tabs/sheets in google sheet

Simple For Loop Google Apps Script

Google-Apps-Script For loop

How can you set the value of a target cell in google sheets within a forEach loop in google apps script?

loop through a script when a sheet name begins with X google apps script

Can I use a variable as index in for loop in python?

How can I change sheet direction from apps script

How can I assign a Google Sheet script to only one sheet?

Google Sheet + App script: How to loop for each with an array