0
votes

I have this following code:

function copyInfo() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var copySheet = ss.getSheetByName("WREQ");
  var pasteSheet = ss.getSheetByName("Orders/Deliveries");

  // get source range
  var source = copySheet.getRange("A2:X");
  // get destination range
  var destination = pasteSheet.getRange(pasteSheet.getLastRow()+1,  3,  1,  1);
    // copy values to destination range
     source.copyTo(destination);
     source.clearContent();
    
}

it copies the information in A2:X from WREQ and paste it at the last row +1 of "Orders/Deliveries" sheet starting from column c. The problem is I want it to delete the row a2:x after that, as it will be automatically created again, before the script once more. I was trying to use something like:

source.DeleteRows();

but keep getting the Error source.DeleteRows is not a function.

I just need it to delete the line after copying it, but I don't know how to do it anymore.

If this is not possible, maybe then if the script could just copy the last value entered at the "WREQ" sheet.

This is needed because if I don't delete it will repeat values and in case of using the source.clearContent(); it will copy the empty spaces, which I don't want.

:(

1

1 Answers

1
votes

deleteRows() is a method in the sheet class.

See if this works

copysheet.deleteRows(2, source.getNumRows())

Reference