Skip to content Skip to sidebar Skip to footer

Google Script .setformula Error With String Value

I'm new to this so please forgive the simple question. I'm trying to insert the following formula into cell E18 of google sheet L2_R1 Final Product: =if(D17='Poor',0,if(D17='Accept

Solution 1:

You can also use setValue() instead:

var r2_fpr1_1 = sheet4.getRange('E18');
r2_fpr1_1 .setValue(`=if(D17="Poor",0,if(D17="Acceptable",1,if(D17="Excellent",2,)))`)

But also setFormula() works just fine:

var r2_fpr1_1 = sheet4.getRange('E18');
r2_fpr1_1.setFormula(`=if(D17="Poor",0,if(D17="Acceptable",1,if(D17="Excellent",2,)))`)

References:

Template literals

Post a Comment for "Google Script .setformula Error With String Value"