I'm working with a sheet that has 2 columns with cells that may have multiple rows in the cell. I'm trying to figure out how to split both cells at the same time (as they both should have the same number of lines in them) and maintain/duplicate the surrounding data for each new split. I've seen a few different ways to accomplish this using both a formula and a script, seen below, but those all seem to hinge on only splitting a single column of cells, not 2 columns.
My data set is below and it's pulling information from a Forms submission, so I'm not able to change how the data is input, I just need to try and figure out the best way to parse the data. Ideally, both cells will have the same lines and will be split on a carriage return (I'm most familiar with CHAR(10) being used) and I just need to figure out splitting both simultaneously. I put together some example data in the sheet linked below. I've also included one example of code that I've found that performs this task on a single column of cells (from here, but is quite old -- I'm also not quite sure how to modify my range to not be column B in the example)
function result(range) {
var output2 = [];
for(var i=0, iLen=range.length; i<iLen; i++) {
var s = range[i][1].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 == 1) {
output1.push(s[j]);
} else {
output1.push(range[i][k]);
}
}
output2.push(output1);
}
}
return output2;
}
Data sample available here:
https://docs.google.com/spreadsheets/d/1edR-pKxx98l01zFE2LBUkWvQJPKQ9IV_LIHieDwf-1I/edit?usp=sharing
Any help would be greatly appreciated!
