0

I've been playing around with Google Scripts and I'm trying to pull some data into a sheet. It all seems to check out except one line where I get a range error, I know (or I think I do) that it has something to do with the OwnerRange but this is a first time for me and I'm still trying to learn as I go.

  ownerSheet.clear();
  var ownerLen = ownerArray.length;
  var ownerRange =  "A1:C" + ownerLen;
  if (ownerLen > ownerSheet.getMaxRows()) {
    var addRows = ownerLen - ownerSheet.getMaxRows();
    ownerSheet.insertRowsAfter(ownerSheet.getMaxRows(), addRows);
  }  
  ownerSheet.getRange(ownerRange).setValues(ownerArray);

I've tried changing the "A1:C" but I get height errors when doing that. The columns that get generated in the sheet are from A to J. The original script is here: https://charlielove.org/?p=10117

Others there are having the same error it looks, with the same line. Thought I'd ask here just in case anyone can help.

  • @mark my answer I didn't no, when the script runs it creates a sheet in my Drive. I just tried changing 'idtoname' to my sheet name, same error. – Mark Jan 21 at 16:11
  • While including a link to the complete script could be helpful, questions on this site should be self-contained. In other words, add a minimal, complete and verifiable example (the fewer code lines as possible to reproduce the problem). – Rubén Jan 21 at 21:35
  • We could provide a lot more assistance if you would provide a complete example. It's kind of hard to get 1/2 of a function to do much of anything. – Cooper Jan 24 at 6:32
0

You could try:

ownerSheet.getRange(1,1,ownerArray.length,ownerArray[0].length).setValues(ownerArray);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.