I'll start by saying I'm very new to this. Here's my problem. I have a GoogleSheet I created to use as a seating chart in my classes. It is designed so that when I click the blue check button the cell where a child's name will appear turns green. It can then be reset by clicking the recycle button in the corner. All of that works fine but only on the first tab of the sheet. I would like to use it across all six tabs, one for each class I teach. Can anyone show me how to share the script across all six sections. Here is the basic code I used:

function A3Green() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheets()[0];

  var colors = [
    ["#00ff40"]// These are hex equivalents

   var cell = sheet.getRange("A3:A3");
   cell.setBackground (colors);

1 Answer 1


The script is already "shared across" all the sheets in the workbook. The 0 on the following line returns the first sheet

var sheet = ss.getSheets()[0];

You could replace the 0 by 1 to get the second sheet, by 2 to get the third sheet and so on.


  • Thank you for the suggestion. Changing 1 variable works but if I try to add a range like [0,1,2,3,4,5,6,7] it doesn't carry across all tabs. Is there a way to carry it across all tabs? Also the notation // get all sheets didn't seem to work either. Dec 13, 2018 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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