Buttons that Automatically Script in Google Sheets

Опубликовано: 03 Март 2026
на канале: Google: Apps, Script, Pillole, Tips and Tricks
16,634
130

Creating a button in Google Sheets that, when clicked, performs operations automatically for us… it's very simple and you don't have to write a single line of code!

In the video I take as an example an expense reporting template which, once completed, can be restored for a new data entry with just one click on our button.

In the example I fill in the expenses form for a hypothetical trip carried out indicating the various information requested, especially the dynamic ones such as the purpose of the mission and the individual items of the expenses for food, accommodation and transport.

At this point the ideas become innumerable, for example I could create a function that starts when you click on a button to automatically save the file in PDF and send it to the administration department or another that saves the information entered in a new tab and reset the main one preparing it for a new data entry.
Cases like the first I explored them with practical examples in my book "Tip high with ... Google Apps Script", available on Amazon: https://www.amazon.it/Punta-alto-Goog... dp / 1794059393 /
In this tutorial I show you the second scenario instead because it allows you to highlight a further simplification, since you can manually write the function in Apps Script or you can have it automatically generated by the system without writing a single line of code and subsequently associate it to a button.
In this case we will use macros, to learn more about the subject I made a video dedicated to this feature that you can find in my channel. For the moment I'll go straight to the point and create a macro to record the operation that I want to associate with the button every time it is clicked. So after launching it, I physically go and duplicate my main sheet in order to keep my report saved and delete the contents of my main sheet. The JavaScript code of the steps I just performed is automatically generated in the form of an Apps Script function called with the name I associated with the macro.
Just insert an image to use as a button (drawing it or loading it from my device), resize it and position it as needed. Then select it with the right mouse button. 3 dots arranged vertically will appear at the top right and when clicked they will open a contextual menu. Choosing the 'Assign script' option will open a modal where the name of the function that we want to associate with the click on the image must be entered. Confirming ... that's it!
The first time you click on the button you will be asked to provide permissions to the script, just follow the wizard. From that moment on, every time the button is clicked, the desired operations will be carried out automatically.

The example in this case is trivial, but just think about how to exploit this potential in Sheets where complex steps and operations are required, and where doing everything manually becomes not only tiring but also prone to making mistakes over time. Where macros do not cover the need, it is possible to intervene with functions created ad hoc, at which point you can create powerful automated tools that will allow you to save a lot of time and money.

As always, I hope you have been useful, subscribe to my channel if you haven't done so yet to stay updated on the release of my new videos and see you soon ... Hello;)

#GoogleAppsScript #JavaScript #GoogleSheets #SimplifiedQuickProgramming