I'm looking for a script for my Google Sheets sheet to change the background color of a specific cell to another color if the value of this cell changes.
With changing the color, a timer starts and changes the color back to the former color after 5 seconds.
As you can see, A1 = B1.
If B1's value changes, A1 gets updated, so its "value" changes. A1 should get a red background color for 5 seconds and after that change back to the former color (or another specified color). The same should happen to A2...A5.
Is this possible? This is my code so far:
function onEdit(e){
var range = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1').getRange(10,2,12,4);
var rangee = e.range;
rangee.setBackgroundColor("#FF6633");
Utilities.sleep(5000);
rangee.setBackgroundColor("#434343");
}
It changes the cell to FF6633 (if I comment the last line out), but doesn't switch back. If I comment the last line in, it does nothing.
Side question: does onEdit() work just on really "editing" the cell value, or does it also work with a formula in this cell, where just the "result value" changes.
If you need further information, please let me know. :)