Custom "Better Sheets tools" menu
onOpen adds menu items like "Refresh dashboard" and "Email weekly summary" that call named functions when clicked.
The onOpen trigger runs an Apps Script function automatically when someone opens the spreadsheet. It is the standard way to add custom menus, show instructions, or refresh lightweight cache without asking the user to run a macro first. Name the function onOpen or bind it as an installable open trigger.
Use onOpen to register a custom menu, set up sidebar launchers, warm a small config range, or show a one-time welcome note for editors. It sets the stage before anyone clicks Run.
Skip onOpen for heavy imports, bulk API syncs, or anything that must run while the file is closed. Users notice slow opens. Use time-driven triggers or a manual menu item for long jobs.
Create a function named onOpen in Apps Script (capital O is required for the simple trigger).
Inside onOpen, call SpreadsheetApp.getUi().createMenu() to add items that call other functions.
Save the project and reload the spreadsheet to test; the menu appears after the sheet finishes opening.
{:"Keep onOpen fast"=>"defer real work to functions the user chooses from the menu."}
For stricter permissions, add an installable onOpen trigger from the Triggers page in Apps Script.
Document menu labels so teammates know which action is safe on production data.
onOpen adds menu items like "Refresh dashboard" and "Email weekly summary" that call named functions when clicked.
onOpen reads a hidden Settings cell; if blank, sets a friendly note in A1 reminding editors to pick their region from a dropdown.
A menu item calls showSidebar() which opens HtmlService UI for a form that writes to the sheet.
Build this without starting from a blank cell
Use a Better Sheets tool for onOpen trigger, then watch a walkthrough when you want the full pattern.
Watch how onOpen trigger works
Guides that explain onOpen trigger in more depth.
Make your data tasks simpler & efficient. Discover the power of automation in Google Sheets with a comprehensive guide that covers everything from triggers to scripts.
Read post →Did you know you can actually code in Google Sheets?
Read post →In this post, we'll cover how to remove rows automatically in Google Sheets using Apps Script, ensuring you save time and streamline your spreadsheet management. You're probably already familiar with the manual way of right-clicking and deleting rows, but there's a more efficient way to handle this—automation! Manual versus Semi-Automatic Deletion You may know that you can manually delete rows in Google Sheets by right-clicking and selecting "Delete row." You can even select multiple rows...
Read post →The onEdit trigger runs a script automatically when someone changes a cell in your spreadsheet. It is one of the simplest ways to make Sheets react to user input without clicking a custom menu. You define the function in Apps Script and bind it to the onEdit event for that file.
Read guide →Triggers tell Apps Script when to run a function: on edit, on open, on a schedule, or when a form is submitted. Simple triggers use reserved names like onEdit. Installable triggers are created in the Apps Script Triggers page and can do more, including running as a specific user or on a timer.
Read guide →A macro records your clicks and keystrokes in Google Sheets, then saves them as an Apps Script function you can run again from the Extensions menu or a keyboard shortcut. Macros are the fastest on-ramp to automation when your task is a fixed sequence of formatting or edits.
Read guide →The Script Editor is the Apps Script workspace inside your spreadsheet where you write JavaScript that talks to Sheets, Gmail, and other Google services. You open it from Extensions > Apps Script. Every function you save can be run manually, bound to a trigger, or linked from a custom menu.
Read guide →Done reading about onOpen trigger?
Membership unlocks 636+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.
Need this once
Jump to a free tool or a single tutorial for this topic.
Learning Sheets for real
Unlock the full library, generators, and templates with membership.