简体   繁体   中英

Cell Flash on Specific Value

I need a cell that flashes on edit only when a specific word, for example "WINNER" , is the value entered (Currently Cells word is populated via an If statement). Have tried modifying the scripting along the lines of :
if( activeCell == "A1"="WINNER" ) but to no avail.

Below is the link to the test sheet.

Flashing Cell

How about this sample? If it doesn't work of blink, installing trigger may be necessary for it.

function onEdit(e) {
  if (e.value == "WINNER") {
    var number = 5; // Number of blink
    for (var i = 0; i < number * 2; i++) {
      if (i % 2 == 0) {
        var color = "white";
      } else {
        var color = "red";
      }
      e.range.setBackground(color);
      SpreadsheetApp.flush();
      Utilities.sleep(300); // Blink speed (ms)
    }
    e.range.setBackground("white") // Cell color is white after blinks were completed.
  }
}

Probably not the best way to do it. I'm sure Google would frown upon me for my poor usage of cpu time. But here it is anyway.

function flash()
{
  var sht = SpreadsheetApp.getActiveSheet();
  var cell = sht.getActiveCell();
  var i = 0;
  var j = 0;
  while(j < 10)//It flashes the active cell for a few seconds
  {
    cell.setBackground('red');
    SpreadsheetApp.flush();//If you don't do the first it won't flash.
    while(i < 100000){i++;}
    i = 0;
    cell.setBackground('white')
    SpreadsheetApp.flush();
    while(i < 100000){i++}
    i = 0;
  j++
  }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM