Cell blink in google sheet

I have a Google Sheet which has 22 sheets. I want to blink a particular cell (suppose A1) in all 22 sheets when the file is opened. I don't know javascript. I managed a script from google but it only blinks only when A1 cell is edited in Sheet1 only, not on every sheet. I want to blink cell A1 in all 22 sheets when the file is opened not edited (because A1 is read-only cell. It will only blink as alert). The script is

function onEdit(e)
{
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var mysheet = ss.getSheetByName("Sheet1");
  var activeCell = ss.getActiveCell().getA1Notation();
  
  if( activeCell == "A1" )
  {
    for(var i=0;i<50;i++)
    {
      if( i%2 == 0 )
        mysheet.getRange("A1").setBackground("RED");
      else
        mysheet.getRange("A1").setBackground("WHITE");
      
      SpreadsheetApp.flush();
      Utilities.sleep(500);
    }
  }
}

Please someone edit the script so that every sheet's A1 cell blink automatically when the file is opened. Thanks in advance.

I don't know javascript.

Upvotes: 0

Views: 262

Answers (1)

David J. Myers
David J. Myers

Reputation: 84

This should give you what you're asking for:

function onOpen(e) {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var allsheets = ss.getSheets();
  for (var i = 0; i < 50; i++) {
    for (var j in allsheets) {
      if (i % 2 == 0) allsheets[j].getRange("A1").setBackground("RED");
      else allsheets[j].getRange("A1").setBackground("WHITE");
    }
    SpreadsheetApp.flush();
    Utilities.sleep(500);
  }
}

To make this script work:

  1. Open a Google Sheets workbook
  2. Click on the Extensions menu and pull down to Apps Script
  3. Paste in the Apps Script shown above and make any adjustments (cell to blink; colors to blink)
  4. Name the script (i.e. "Blink on All Sheets") Click the Save icon

For more info, see Custom Functions in Google Sheets.

Upvotes: 0

Related Questions