0
votes

I have two buttons on a Google sheet, each running a different script. I'd like to be able to click one button and have both scripts run. Is this possible?

My first button/script clears multiple ranges:

{function clearRange() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Pricing 
Comparison');
sheet.getRange('B2:B5').clearContent();
sheet.getRange('B7:B12').clearContent();
sheet.getRange('B14:B16').clearContent();
sheet.getRange('B23').clearContent();
sheet.getRange('B26').clearContent();
sheet.getRange('B28:B29').clearContent();
sheet.getRange('E2:E20').clearContent();
sheet.getRange('H13').clearContent();
sheet.getRange('J13').clearContent();

}}

}}

My second button/script reverts a cell back to a specific value:

function doTest() 
{SpreadsheetApp.getActiveSheet().getRange('A19').setValue('Multi-tenant 
Cloud');
}

I'd love for both of these functions to execute when clicking one button. Thanks for your help.

1
You could copy-paste the code into a new button, but I doubt that's what you really want. - SIGSTACKFAULT
Yes. See answer below. - Cooper

1 Answers

0
votes

Use a third function() Like this:

function combine() {
  clearRange();//you can change the order if required and add as many as you wish
  doTest();
}

Attach combine to your button.