I'm new here in this site and also new in Google Apps Script.

I'm trying to find an example to create a Pushbutton inside Google sheets.

I've found something saying it is "deprecated".

What I expect to do is putting a button called "Move to Sent" that when pressed must count some lines till the line saying "END" and then move the content of those lines to another location in the same sheet.

It looks quite simple to me but I've got stuck in the very beginning.

Some help would be appreciated at least to point me in the right direction to find out.


As said in the deprecation message you found, user interfaces can be created with the HTML Service.

But if you just want to create a button that is displayed in your sheet, there is an easier way.

Click Insert → Drawing and draw a text box. Give it a background color and a border, so that it looks something like this:

A text box looking like a button

Make sure you position the text box to the very top left corner of the drawing editor window.

When you're satisfied, click the Save and close button to return to your spreadsheet. The button (your drawing) is now positioned on your spreadsheet. You can click and move it anywhere you want.

Now click the button to select it, and click the little down-pointing triangle and select Assign script:

Button positioned on spreadsheet

In the prompt that pops up, assign a function name to your button, e.g. clickMe.

Next, click Tools → Script Editor to open the Script Editor window. Here, define your function clickMe (or whatever you entered in the Assign script popup):

function clickMe() {
   // Here, implement your script logic, e.g.:
   Browser.msgBox("You clicked me");

Click the Save button (give your script file a name when prompted) and return to your spreadsheet. Try to click the button. The first time you do so, you will be asked to give the script permission to run, and to access your spreadsheets. Having done so once, clicking the button will show a popup saying You clicked me.

I have created an example spreadsheet to demonstrate, feel free to copy it. You have to be logged in order for the button to work.

|improve this answer|||||

I want to add another way to create a Pushbutton inside Google sheets described in This Post.

The apps UI only works for panels. The best you can do is to draw a button yourself and put that into your spreadsheet. Than you can add a macro to it. Go into "Insert > Drawing...", Draw a button and add it to the spreadsheet. Then click it and click "assign Macro...", then insert the name of the function you wish to execute there. The function must be defined in a script in the spreadsheet.
Alternatively you can also draw the button somewhere else and insert it as an image.

|improve this answer|||||
  • What I'd like to know is how this can be done using the HTML service mentioned HERE. – Shirley Temple Jun 4 '17 at 12:31
  • I'm not sure I understand how this answer is any different from mine? – Vidar S. Ramdal Jun 12 '17 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.