I need to write several formulas in google sheets, through google apps script. So that the script is not very slow, I used setValues() and wrote the formulas (which are SUM and SUM.IF) as a string, but although they are written correctly in the sheets, it does not read them correctly and I get an error #¿NAME? ? I add a simplified example.
function escribirFormulas(){
var ssHoja5 = SpreadsheetApp.openById('xxxx').getSheetByName('Hoja 5')
var array = [['=SUMA(25+25)','=SUMA(2+2)'],['=SUMA(25+25)','=SUMA(2+2)']]
ssHoja5.getRange('A1:B2').setValues(array)
}
Regardless of your account settings and spreadsheet settings, when you add formulas using Google Apps Script, instead of using the Spanish function names, in this case
SUMA
you should use the function names in English, in this caseSUM
.By the way, instead of using
setValues
the appropriate thing would be to usesetFormulas
.Related
References