I am new to Google Apps Script and the docs are a little fuzzy on the returned data from a method call. I want to loop through a range, but it is coming back as null. What am I doing wrong?

var currentSheet = SpreadsheetApp.getActiveSheet();
var loopRng = currentSheet.getRange('B4:B34');
var counter = 0;


for(var i = 0; i < loopRng.length; i++) {
  • When a question receives an answer that correctly address what was original asked it should not be edited in such way that it will invalidate the answer. Instead you might post a new question. By the other hand when and edit required avoid to label the changes with EDIT, UPDATE or anything similar, focus on make the question easy to be read and understood. – Rubén Apr 19 at 20:27
  • You changed my edit? You can do that? – CodeMints Apr 19 at 21:28
  • Yes, I rolled back the revision 1. I earned the corresponding privileges and I'm a diamond moderator. – Rubén Apr 19 at 21:31

length is not a property of a Class Range object. Instead of


you might use




to iterate over the range rows or




to iterate over the range columns


  • That makes sense. Thank you. However, I'm still a bit stuck. I've read through the methods on the sheet and range class. I am just missing something. I have added more detail as to what I am trying to accomplish in my original question. I really appreciate your time. – CodeMints Apr 19 at 19:40
  • I think my confusion in in the 2D array and wrapping my head around that. – CodeMints Apr 19 at 20:05
  • On this site there are already a lot of questions and answers that read/write data to Google Sheets but maybe you should spend some time learning the basics of JavaScript how to handle Arrays. – Rubén Apr 19 at 20:36
  • I already looked at the other questions. I got it though thank you. Have a great day. I hope whatever issues you have are resolved. – CodeMints Apr 19 at 21:30

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.