I am new in Google Sheets. I am trying to make a spreadsheet on my company. It will move the whole row to another sheet when I click on checkbox. I wrote this code but it sometimes works and sometimes doesn't. Would anyone help me?
Here's the code
function onEdit(e) {
const src = e.source.getActiveSheet();
const r = e.range;
if (src.getName() != "Teklifler" || r.columnStart != 11 || r.rowStart == 1) return;
const dest = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Onaylanan");
src.getRange(r.rowStart,1,1,15).moveTo(dest.getRange(dest.getLastRow()+1,1,1,15));
src.deleteRow(r.rowStart);
if (src.getName() != "Onaylanan" || r.columnStart != 15 || r.rowStart == 1) return;
const desti = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Tamamlanan");
src.getRange(r.rowStart,1,1,15).moveTo(desti.getRange(desti.getLastRow()+1,1,1,15));
src.deleteRow(r.rowStart);
}
Here's the spreadsheet
https://docs.google.com/spreadsheets/d/1CxWCSNivWhXTQSpqlriMjapg1NssSfSEvbm8-Ay_a3A/edit?usp=sharing
Thanks for helping