I want to copy the values generated by a complex scripted query to another sheet, for users to work on without deleting the original query.

The query generates a variable range of data, depending on parameters passed, so I cannot hard code the range to copy. But it seems the problem is more complex than that...

Sample query and output

I tried to pick the range using GetDataRange(); that returns an error (TypeError: Cannot call method "getDataRange" of null.).

  // copy data to dashboard:
  var dashTab = thisSht.getSheetByName("Dashboard");
  dataTab.getDataRange().copyTo(dashTab.getRange('A5'), PASTE_VALUES, false);

Checking that there is data there:

  var dataRange = dashTab.getRange('B6');

shows an empty array [[]] in the log.

So how can I do this?

  • ...ctrl+c > ctrl+shift+v would be the manual way... – user0 Apr 22 at 11:34
  • Indeed it is, and works fine. But I cannot yet find a way to do this in code... – SM. Apr 22 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.