Fruckubus Crunt
Fruckubus Crunt

Reputation: 199

Google Sheets Script Execution Time Impractically Slow

I have the following code linked to a button (drawn rectangle):

  var sheet = SpreadsheetApp.getActive().getSheetByName('Jobs');
  sheet.getActiveRange().setBackground('#ACB6FF');

All this does is change the background color of the selected cells, however it takes almost 2 seconds to do it. Is this normal, expected behavior? Is there something I'm missing when it comes to running scripts?

Upvotes: 1

Views: 173

Answers (1)

Wicket
Wicket

Reputation: 38435

There are multiple factors that could affect the execution time some of them are not on the script developer / user side.

Regarding your specific case, if your button is on the Jobs sheets replace both lines in the question by

SpreadsheetApp.getActiveRange().setBackground('#ACB6FF');

This could reduce the execution time because it makes fewer Google Apps Script classes / methods calls.

Upvotes: 1

Related Questions