0

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);
}
0

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.

Reference

  • 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. – James-David Johnson Dec 13 '18 at 17:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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