I'm currently working in a Google Sheet that has about 12,000 rows. Because of the layout, I want to group every 5 rows, then skip one, then group the next 5.

Right now, I have as script that is accomplishing the task - but it is super inefficient. I am unsure how I can get this pattern to loop, so I've set the code for each individual range.

It wasn't bad setting up, because I used basic Sheets functions to automatically get the numbers and text layout. From there, I just copied and pasted it in.

As you are probably already thinking, it times out constantly, so I am just doing it in bunches. While this works, I am sure there is a better way that I would love to learn.

Here is my code (took a snippet, since the full one ranges up to 12,000 like I mentioned):

function groups() {
  var spreadsheet = SpreadsheetApp.getActive();


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.