I am trying to make a script that creates a new tab based on data submitted from a form and inserts a formula into the new tab on creation. The last line of the script is giving me a syntax error. "Missing ) after argument list". All parenthesis seem to be closed properly. Am I missing something?
function makeTabs() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var last = sheet.getLastRow();
for(var i=0; i<last; i++){
var tabName = sheet.getRange(i+1,1).getValue();
var create = ss.insertSheet(tabName);
var tab = ss.getRange('A2').activate();
var tab = ss.getCurrentCell().setFormula('=QUERY(\'Form Responses 1\'!A2:R,"select * where C="'tabName'",-1)")');
}
}
... C=" + tabName + " ...C=""' +tabName+ '"""