Reputation: 863
I've followed the instructions from: https://developers.google.com/apps-script/execution_custom_functions to create a custom function.
Neither my functions or even cut and paste from the tutorial works: the functions aren't available to my spreadsheets. I've tried saving a version and publishing as a web app - with no change. I tried Google Chrome and Firefox, same result. Am I missing something really obvious here?
Upvotes: 9
Views: 13310
Reputation: 21
You will need to add JS-Docs before your function to make it work. https://developers.google.com/apps-script/guides/sheets/functions#autocomplete
/**
* Divides the input value by 2.
*
* @param {number} input The value to divide.
* @return The input divided by 2.
* @customfunction
*/
function HALF(input) {
return input / 2;
}
Upvotes: 0
Reputation: 198
Does your Chrome Popup setting determine whether the customFunction
autocompletes when you enter in in a cell? If so how would you add it as an allowed exception in settings? Enable autocomplete is checked under the tools menu in the spreadsheet.
My function works fine if run from the script editor but does not autocomplete when =myCustomFunction
or =myCustomFunction(
entered in a cell.
Upvotes: 0
Reputation: 179
You need to have a comment with @customfunction in it above your custom function. Google Sheets will then add you custom function to the autocomplete menu.
Upvotes: 17
Reputation: 789
Not sure if this is what you ran into...but what happened to me is, I didn't see my custom function in auto-complete and I thought it's not working. But if you just type =double(A1) in a cell (using the official example, assuming there is something in A1...), it will compute!
Upvotes: 2