Currently, I am exploring GAS (Google Apps Script) and analyzing the following function:
function myFunction(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cell = sheet.getRange("B5");
cell.setFormula("=SUM(B3:B4)");
}
I am attempting to create a formula in GAS that combines two values with a Randbetween formula. When I input the code directly into a cell, it produces the desired result:
=CONCATENATE("61", RANDBETWEEN(10, 99), "@text") 6177@text
However, when implementing these principles in GAS, an error message is returned.
Missing ) after argument list. (line 6, file "Code")
Below is the code I am using:
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cell = sheet.getRange("A1");
cell.setFormula("=CONCATENATE("61", RANDBETWEEN(10, 99), "@text")");
}
Why is this code failing to execute properly? How can I resolve this issue?