I have a few Simple Custom Functions that I use all the time. I have recently run into a spreadsheet that I desperately need to use them in, but when I try to use even the most basic custom functions, I get "#NAME?" with a hover text of "unknown function".
Even deleting all other code, and trying just this simple function, doesn't seem to work:
function double(d) {
return 2*d;
}
When I duplicate the spreadsheet, the code that comes with it DOES work.
A few Notes:
This is a Google Apps for Enterprise account.
I was originally not the owner on this spreadsheet, but have since become the owner, thinking that this might be the cause.
The spreadsheet originally had protected regions, which have since been removed, thinking that this might be the cause.
This spreadsheet is shared with hundreds of people, so I really want to find the root cause and fix it.
Any thoughts?
I faced the same problems. I here document, what worked for me.
To create a new custom function, I did the following:
=CustomFunctionName()
This worked.
Now, when I wanted to reuse the same in another spreadsheet, there are 2 ways to do that.
Make Copy
of the sheet in which the custom function is written.#1 Make Copy of the sheet in which the custom function is written.
In this way, the whole custom function code gets duplicated. So, if any changes needs to be done in the custom function, the change must be done in all the copied files. Also, once the sheet is copied, the custom function does not simply works. I had to delete the cells & reenter the function names again, to get them working.
#2 Make library of custom functions and reuse them in other sheets, by writing custom functions specific for a particular sheet.
This is better, because, the core logic will stay in one place. Only wrapper functions will be written for each sheet, in which the custom functions are used.
To create a library:
To use a library:
+
button next to the Library section on the left.Library Code:
Let's say, while including this library into a spreadsheet, I entered the identifier as
utility
. So, in the script editor, I would write like this:How to update a library and use the updated code in spreadsheets?
To update a library:
To use the updated library:
Library
section(on the left).Version
input & click "Save".Now, you can call the new functions in the same way you did previously & the existing functions will work in the new way(if there are any changes to the existing functions).