I have a website for summer camp. Every registration automatically ends up in a google sheet. I would like to split the registrations into multiple rows.
The Google spreadsheet I've inherited for this project includes a column C - H, with multiple children info listed in the same cell, separated by line breaks (ie CHAR(10) ). There is one registration per row. The number of lines in (Column C to H) a cell varies row-by-row. My initial sheet looks like this:
I need to do the following to optimize this sheet:
Split each multi-line cell so each child appears on its own row. This requires that new row/s be inserted beneath the original row. duplicate the data from all other cells on the original row (i.e. from columns A & J:V), so that each new row contains the full data for a child. I need an automated process - I'll have about 3000 registrations to process so can't do this with any manual steps.
The sheet should then look like this:

I've tried using this custom script in google sheets but it didn't work:
function result(range) {
var splitCol = 1; // split on column B
var output2 = [];
for(var i=0, iLen=range.length; i<iLen; i++) {
var s = range[i][splitCol].split("\n");
for(var j=0, jLen=s.length; j<jLen; j++) {
var output1 = [];
for(var k=0, kLen=range[0].length; k<kLen; k++) {
if(k == splitCol) {
output1.push(s[j]);
} else {
output1.push(range[i][k]);
}
}
output2.push(output1);
}
}
return output2;
}
All help is welcome! Thanks.
