Question

I'm trying to figure out how I can write and run a custom function in a Google spreadsheet and I've been following this google tutorial.

However at the time of this posting, I fear that this tutorial is out of date. I followed the steps, but see no way to access my in2mm function from within the spreadsheet that I started at. The tutorial suggests the following to make it show up

You can manually start the scan by going to Tools > Script Manager... and clicking the Reload button.

However, no such menu item exists.

Tools drop down, no

Just cut off in that screenshot is a "Script Center Menu", which has just one option for "Read Data". It's unclear what that does. It's also unclear how the "Script Editor" ends up tying back into the existing spreadsheet to become available...

Does anyone know the current steps required to write a simple google script function and then access it from within a Google spreadsheet?

Was it helpful?

Solution

I had the same problem, and while the tutorial and Sum Ting Wong's answer actually do work, it didn't help in my case.

The sheet I was trying to use the custom function from was in the old format. So I converted it to the new format,created a custom function, and now I can use it the sheet.

Here's how you see if it's an old format sheet Check out the new Google Sheets

You can tell that a spreadsheet has been created in, or upgraded to, the new Google Sheets if it has a green checkmark at the bottom.

and here's how to convert it to the new format: Moving spreadsheets to the new Google Sheets

you can manually move spreadsheet contents into the new version of Sheets to take advantage of new functionality, following any of these steps:

  • Copy and paste content from a spreadsheet created in the old version to a spreadsheet created in the new version.
  • In a spreadsheet created in the old version, click the down arrow next to a sheet tab and click Copy to…, and copy the sheet (and its contents) to a spreadsheet created in the new version.
  • Export the contents from the old version and import them into a spreadsheet created in the new version.

OTHER TIPS

forget the reload button hint.

if you have in the first step write your function in the script editor and save it.

 function in2mm(inNum) {               // Function to convert from INCHES to MILLIMETERS

   var outNum = 0;                     // this will hold the answer
   var factor = 25.4;                  // multiply input by this factor to get output

   if (typeof inNum != "number") {     // check to make sure input is a number
       throw "input must be a number"; // throw an exception with the error message
   }

   outNum = inNum * factor;            // calculate the answer

  return outNum;                      // return the answer to the cell which has the formula
}

for your second step write e.g. in cell A1 of your sheet, to call the function

=in2mm(10)

important is that you call your function-name started with the equal sign =

if you do a type-mismatch by your second step you get the message

#NAME?

there is no mystic and no out of date ;-) btw i imagine they talk from the browser reload button

Custom Function still work in google sheets.

function GETKWEEKDAYFROMNBR(weekdayNbr) {
    var weekdays =  ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
    return weekdays[weekdayNbr];

}

usage example:

=GETKWEEKDAYFROMNBR(WEEKDAY(A2,2))

I've got the same problem. I've had a spreadsheet open for a few days and under Tools there are three script options, those being Script Gallery, Script Manager and Script Editor.

I started a new sheet and went to the script editor, and there's only two options available, just like in your image. If I select Script Gallery I get this message;

Script gallery is now the add-on store In the new Google Sheets, the script gallery has been replaced with the add-on store. Click the new Add-ons menu to get started. Learn more

The only solution I can see to get the script to work is by running it from within the script editor itself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top