Home > database >  How cross out multiple columns on same row and format cell colour when box ticked
How cross out multiple columns on same row and format cell colour when box ticked

Time:09-18

My script is able to cross out the first column juste after the the check box, while I'm looking to cross out the whole row.

enter image description here

Also, I'd like to apply a different colour when the box is ticked.

enter image description here

function onEdit(e){
  var mySheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var myRange = e.range;
  var mySheetName = mySheet.getSheetName();
  var myStatus = myRange.getValue();
  var currRow = myRange.getRow();
  var currCol = myRange.getColumn();
  var myItem = mySheet.getRange(currRow, currCol   1);
  if (
    mySheetName === 'Feuille1'
    && currCol === 1
  ) {
    if (
      myStatus
    ) {
      myItem.setFontLine("line-through");
    } else {
      myItem.setFontLine(null);
    };
  };
};

CodePudding user response:

Set Line Through

function onEdit(e) {
  //e.source.toast("Entry")
  const sh = e.range.getSheet();
  if (sh.getName() == 'Feuille1' && e.range.columnStart == 1) {
    let rg = sh.getRange(e.range.rowStart, 2, 1, sh.getLastColumn() - 1);
    if(e.value == "TRUE") {
      rg.setFontLine('line-through')
    } else {
      rg.setFontLine('none')
    }
  }
}

Demo:

enter image description here

  • Related