google apps script - Why can't you use setValue in a custom function? -


i'm curious, know why can't use setvalue write in different cell in custom function?

the readme explains can't this, doesn't give reason on why: link

custom functions return values, cannot set values outside cells in. in circumstances, custom function in cell a1 cannot modify cell a5. however, if custom function returns double array, results overflow cell containing function , fill cells below , right of cell containing custom function. can test custom function containing return [[1,2],[3,4]];.

anyone knows if there reason this?

i think quite logical. when you're calling custom function in cell, a1, expecting function calculation (or whatever) , place result in a1. if want see result in b1, you'd write same formula in b1.

as doc explains, there might cases want function return more 1 value in case, returning 2d array populate cells adjacent 1 formula called.

in case, can give use case have want populate different cell using custom function. can call script in other fashions (not formula) , have modify cell want.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -