0

The script I found in this thread works perfectly. It pastes the 18 rows from the one sheet that uses importxml into a values-only sheet, at the bottom, so that I can keep records of all the imports.

Is there something I could add to it that would paste the rows in reverse order? I don't mean pasting at the top of my values-only sheet, I mean pasting at the bottom but in reverse-order.

Here is the script that is referenced in that link (modified for my usage):

function copyPaste() {
  var ss=SpreadsheetApp.getActive();
  var srcsh=ss.getSheetByName('Imported');
  var dessh=ss.getSheetByName('ImportedValues');
  var srcrg=srcsh.getRange('A6:P23');
  var data=srcrg.getValues();
  var desrg=dessh.getRange(dessh.getLastRow() + 1,1,18,16);
  desrg.setValues(data);}

Background: The import gets the info I need in a newest first order, and I would like my Values-only sheet to maintain an oldest-first order.

lise
  • 163
  • 1
  • 9
  • I have to apologize for my poor English skill. Unfortunately, I cannot see the vision of your situation from your question. So can you provide the Spreadsheet including the sample input and output values? By this, I would like to think of the solution. Of course, please remove your personal information. – Tanaike Feb 15 '20 at 01:58
  • See https://stackoverflow.com/a/60213955/ – TheMaster Feb 15 '20 at 06:17
  • @Tanaike my question has been answered by Cooper, but thanks all the same. – lise Feb 18 '20 at 04:16
  • Thank you for replying. I'm glad your issue was resolved. – Tanaike Feb 18 '20 at 07:09

1 Answers1

1
function copyPaste() {
  var ss=SpreadsheetApp.getActive();
  var srcsh=ss.getSheetByName('Imported');
  var dessh=ss.getSheetByName('ImportedValues');
  var srcrg=srcsh.getRange('A6:P23');
  var data=srcrg.getValues();
  var rdata=data.map(function(r){return r;}).reverse();
  var desrg=dessh.getRange(dessh.getLastRow() + 1,1,18,16);
  desrg.setValues(rdata);
}
Cooper
  • 59,616
  • 6
  • 23
  • 54