Google Spreadsheet: Script to change background color of a cell based on a hex code in the neighboring cell - Stack Overflow
Wed Aug 14 2024 09:49:04 GMT+0000 (Coordinated Universal Time)
Saved by @baamn #javascript
The code below only works on newly entered text. For pre-existing text, rename the function and modify it to check the desired column automatically instead of functioning as a trigger (or check the active range if you want to select only certain cells). No muss, no fuss. The regular expression assumes that a valid hex color code is a string that starts with an octothorpe and is followed by either 3 or 6 characters, each of which must be 0-9, A-F, or a-f. SpreadsheetApp.flush() may not be strictly necessary, but it's supposed to afford real time updating of changes in this sort of situation
https://stackoverflow.com/questions/30766943/google-spreadsheet-script-to-change-background-color-of-a-cell-based-on-a-hex-c?rq
Comments