Google-sheets – Move data script

google sheetsgoogle-apps-script

I am setting up a script to copy data from one location and paste values into another location (same tab). However it is only picking up the first line. How can i get it to pick up the whole range ?

function moveValuesOnly() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var source = ss.getRange("RUNSHEET!H4:AC20");
  var destSheet = ss.getSheetByName("RUNSHEET");
  destSheet.appendRow(source.getValues()[0]);
}

Best Answer

You have to remove

destSheet.appendRow(source.getValues()[0]); 

by something else because

appendRow only adds one row of values

and

source.getValues()[0]

returns only the values of first row of source

That something else could be one of the methods getRange and then setValues(source.getValues()) or you could use copyTo

There are a lot of examples on this site.

Reference