EN
Google Sheets - how to add a custom menu list
0
points
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.
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!");
}