Patpower
Patpower

Reputation: 1

Unrecognized function when add formula to a google sheet using script

I have a formula in my sheet that is: =texte(maintenant();"hh:mm:ss") that works fine to display the time, but when I use google script to add the formula like this: range33.setFormula("=texte(maintenant();\"hh:mm:ss\")"); it show #NOM? unrecognized function "texte"and the formula is the same words for words... Is there a setings somewhere? I just dont understand!

Upvotes: 0

Views: 75

Answers (2)

Patpower
Patpower

Reputation: 1

Solved! I just put the formula in english within the scripteditor wich is set to english and it automatically translate it to french in my sheet and it works now!

Upvotes: 0

Marios
Marios

Reputation: 27400

Issues:

  1. Use template literals to construct the formula string

  2. texte and maintenant are locale words for text and now therefore use text and now instead otherwise the formulas won't be translated properly in the sheet and it will show an error.

Solution:

range33.setFormula(`text(now();"hh:mm:ss")`)

Upvotes: 1

Related Questions