setValue to QUERY() formula doesn't work?
-
26-09-2019 - |
Question
Part of my spreadsheet's script runs the following piece of code:
temp.getRange(1, 1).setValue("=QUERY(data!A1:H125, \"Select A\")");
As you might expect, this puts =QUERY(data!A1:H125, "Select A")
into the A1
cell BUT the formula gives an error (#NAME, error: Unknown range name data!A1)
.
I know the formula is correct because if I copy and paste it into the neighboring
cell everything works fine. I do have a sheet called 'data' and it is full of
data in the range A1:H125.
Any help on this problem would be greatly appreciated.
Solution
I found the answer on the Google support forums. The setFormula function is required rather than the setValue function.
ie. temp.getRange(1, 1).setFormula("=QUERY(data!A1:H125, \"Select A\")");
should work
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow