Home > Software design >  Moving row to another tab based on Check Box
Moving row to another tab based on Check Box

Time:10-12

I am trying to move rows from one tab to another tab based on check box but it appears that have something wrong. I appreciate any help to figure out the issue. Thank you,

https://docs.google.com/spreadsheets/d/17lgPUBWaVTxt3QlmETJh7xcAPn9MgxC_gcolhxPrs6k/edit?usp=sharing

CodePudding user response:

Done in your sheet:

function onEdit(e){
  const sheet = e.source.getActiveSheet();
  const range = e.range;
  const value = e.value;
  const row = range.getRow()

  if (
    sheet.getName() === "testing" &&
    row > 2 &&
    range.getColumn() === 13 &&
    value == "TRUE"
  ) {
    const target = e.source.getSheetByName("Completed")
    const rowValues = sheet.getRange(row,2,1,11).getValues().flat()
    rowValues.push(new Date())
    target.appendRow(rowValues)
    sheet.deleteRow(row)
  }

}

CodePudding user response:

function onEdit(e) {
  const sh = e.range.getSheet();
  if (sh.getName() == "testing" && e.range.columnStart == 13 && e.value == "TRUE") {
    var numColumns = sh.getLastColumn();
    var targetSheet = e.source.getSheetName("Completed");
    var target = targetSheet.getRange(targetSheet.getLastRow()   1, 1);
    sh.getRange(e.range.rowStart, 1, 1, numColumns).moveTo(target);
    sh.deleteRow(e.range.rowStart);
  } 
}
  • Related