Google Spreadsheet: Script to change background color of a cell based on a hex code in the neighboring cell - Stack Overflow

PHOTO EMBED

Wed Aug 14 2024 09:47:58 GMT+0000 (Coordinated Universal Time)

Saved by @baamn #javascript

function onEdit() {

  var sheet = SpreadsheetApp.getActiveSheet();
  var range = sheet.getDataRange();
  var actCell = sheet.getActiveCell();
  var actData = actCell.getValue();
  var actRow = actCell.getRow();
  if (actData != '' && actRow != 1)  //Leaving out empty and header rows
  {
    range.getCell(actRow, 2).setBackground(actData);
  }

}
content_copyCOPY

https://stackoverflow.com/questions/30766943/google-spreadsheet-script-to-change-background-color-of-a-cell-based-on-a-hex-c?rq=3#:~:text=Although%2C%20this%20only%20colors%20one%20cell%20at%20a%20time%2C%20but%20it%20portrays%20how%20you%20can%20set%20a%20background%20color%20based%20on%20cell%20input.

https://stackoverflow.com/questions/30766943/google-spreadsheet-script-to-change-background-color-of-a-cell-based-on-a-hex-c?rq