Reputation: 1
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
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:
For more info, see Custom Functions in Google Sheets.
Upvotes: 0