Search code examples
google-apps-scriptgoogle-sheetscustom-function

Is there a way of creating a new arithmetic function in Google Sheets?


I was wondering if there is a way of adding my own arithmetic function to a Google Sheet. I want it to work like this:

When I type into a cell =myFunc(B2, B3) (for example) it will fill in the cell with the return value of myFunc. One way I suppose I could do this is to check if I have typed that combination anywhere in the spreadsheet and then replace it with the desired output using Google Apps Script, but this seems inefficient.

Is there another way I could accomplish this, such as with an addon?

Thank you for your help.


Solution

  • You're looking for custom functions. Any valid JavaScript function in Tools > script editor(a bound script file) can be called in any cell of that spreadsheet.