lundi 22 mars 2021

Copy range and paste it to another Spreadsheet using checkbox as trigger

I am a begginer in this and I don't understand what's the problem with my code. I pretend to move row by row to another SpreadSheet when the user clic the checkbox used as trigger onEdit().

function onEdit(e){

    var range = e.range;
  //Source sheet
    var ss = e.source;
    var sn = ss.getActiveSheet().getName();
  //Destination sheet
  var es = SpreadsheetApp.openById('GoogleSheetID');
  var csh = es.getSheetByName('SheetName');
  
  //Aprobación
  var move = range.offset(0,-2).getValue(); //It's a column that have the value approved/rejected

    if(move == "Approved" && sn == 'SheetName' && e.value == "TRUE"){
    var abc = ss.getRange(2,5,1,12).getValues();
  //Copy matched ROW numbers to j
  j.push(1);
  csh.getRange(csh.getLastRow()+1,1,data.length,data[0].length).setValues(abc);
    }
}

Thank you for your help!




Aucun commentaire:

Enregistrer un commentaire