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();
spreadsheet.getRange('2062:2066').activate()
.shiftRowGroupDepth(1);
spreadsheet.getRange('2068:2072').activate()
.shiftRowGroupDepth(1);
spreadsheet.getRange('2074:2078').activate()
.shiftRowGroupDepth(1);
spreadsheet.getRange('2080:2084').activate()
.shiftRowGroupDepth(1);
spreadsheet.getRange('2086:2090').activate()
.shiftRowGroupDepth(1);
spreadsheet.getRange('2092:2096').activate()
.shiftRowGroupDepth(1);
};