简体   繁体   中英

Set formula for each new tab/sheet

I am trying to assign a formula to each new tab. I am getting an error code (Missing ] after element list. (line 10, file "Code")

function makeTabs() {

var ss = SpreadsheetApp.getActiveSpreadsheet();

var sheet = ss.getActiveSheet();

var last = sheet.getLastRow();//identifies the last active row on the sheet

//loop through the code until each row creates a tab.

for(var i=1; i<last; i++){

var tabName = sheet.getRange(i+1,9).getValue();//get the range in column I and get the value.

var create = ss.insertSheet(tabName);//create a new sheet with the value

var formulas = [

  ['=transpose('Form Responses 1'!J2:O2)'],

  ['=Arrayformula(IF(A2:A="",,VLookup(A2:A,ImportedData!A1:S,{2,11,15,18,17,19},0)))']] ;


var cell = sheet.getRange("A2:B2");

cell.setFormulas(formulas);
}
}

Where am I going wrong? Thanks!!

尝试像这样转义内部单引号:

['=transpose(\'Form Responses 1\'!J2:O2)']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM