Languages
[Edit]
EN

Google Sheets - how to add a custom menu list

0 points
Created by:
Efe-V
409

In this article, we would like to show you how to add a custom menu list in Google Sheets.

Google allows us to modify some elements of the sheet appearance. With the help of Apps Scripts, we can add our additional menus to our sheets - alongside such as Tools, Help, etc.

Example result:

Quick solution

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Menu title')
    .addItem('Menu item title 1', 'functionName1')
    .addItem('Menu item title 2', 'functionName2')
    .addToUi();
}

function functionName1() {
  // some code here...
}

 

Practical example

Below you will see how it works in practice.

Google Sheets - how to add a custom menu list

Note: 

The first time you run a function created in Apps Script you have to go through the authorization process described here - Google Sheets - Authorization Required.

Used code:

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('My functions')
    .addItem('Show message', 'showMessage')
    .addToUi();
}

function showMessage() {
  Browser.msgBox("Hello!");
}
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Google Sheets

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join