Home > Mobile >  Copy active row to another sheet with last row first empty cell
Copy active row to another sheet with last row first empty cell

Time:01-13

I have 3 sheets. Example, my main data is in Sheet1 if I input a data on Row 14 which is the ACTIVEROW then in that column let says D14, contains "N/A" or "1" value I want to copy that whole row data and paste to Sheet2 ELSE it paste on Sheet3 to the lastrow first empty cell.

enter image description here

https://docs.google.com/spreadsheets/d/1CWqKF6Ta7_Tdtzzx47z7TZjzdGWPmi_tFbsRtdEWU3k/edit#gid=2100307022

Sorry for the lack of information. I provide an example of sheet or image above for additional info. Example, I want to input new data in Sheet 1 if the value in the cell is "Male" copy the whole row and paste it to the Sheet!Male else if the value is "Female" it will paste it to the Sheet!Female.

CodePudding user response:

function onEdit(e) {
  const sh = e.range.getSheet();
  if(sh.getName() == "Sheet1" && e.range.columnStart == 14) {
    let vs = sh.getRange(e.range.rowStart,1,1,sh.getLastColumn()).getValues();
    if(e.value == "N/A" || e.value == 1) {
      let dsh = e.source.getSheetByName("Sheet2");
      dsh.getRange(r.range.rowStart,1,1,vs[0].length).setValues(vs)
    } else {
      let dsh = e.source.getSheetByName("Sheet3");
      dsh.getRange(dsh.getLastRow()   1,1,1,vs[0].length).setValues(vs);
    }
  }
}
  • Related