Documentation packages/harismruti-path-tracker/FUNCTIONS.md

Custom Functions in Google Sheets (harismruti-path-tracker)

← Google-Apps-Script-Projects Overview View Source Markdown ↗
Marketplace & Documentation ScreenshotsGoogle Workspace Marketplace & OAuth Consent Screen Submission GuideCustom Functions in Google Sheets (gurukul-account-manager)Tools (gurukul-account-manager)Google Apps Script (gurukul-account-manager)Google API Directory (gurukul-account-manager)Custom Functions in Google Sheets (harismruti-path-tracker)Tools (harismruti-path-tracker)Google API Directory (harismruti-path-tracker)Custom Functions in Google Sheets (inventory-management-system)Tools (inventory-management-system)Google Apps Script (inventory-management-system)Google API Directory (inventory-management-system)

Custom Functions in Google Sheets

Google Sheets has a number of built-in formula functions such as =SUM() that enable quick calculations on spreadsheet data. Custom functions are simply functions that you define yourself, using Apps Script. Once you've defined a custom function, you can use it anywhere in your spreadsheet, just like a built-in function.

This section shows you how to create a custom Sheet functions locally and upload it to your Apps Script project.

  1. Create a new file in the function folder and append a .js extension to the file name.
  1. Write the sheets function in the new file and append a JSDoc comment blocks to explain what your function will do. See example

In this comment, you can identify two parts: the function description and annotations that describe the function's parameters and return type.

@param: You can use the @param annotation to describe each parameter passed into the function.

@return: You can utilize the @return annotation to describe what the function returns.

@customfunction: You should always add @customfunction in any custom function's doc comment. This annotation notifies Sheets to autocomplete your custom function just as Sheets autocomplete built-in functions when you type a function name in a cell as seen below:

Save the file. The functions file will automatically get uploaded to the Apps Script project with the comment block intact.

The comment block is required for Google Sheets to autocomplete for custom functions much like for built-in functions. As you type a function name in a cell, you will see a list of built-in and custom functions that matches what you enter.

Guidelines for Naming custom functions

Before writing your own custom function, there are a few guidelines to know.

← Back to Google-Apps-Script-Projects