I had a lot of help years ago creating a function that would help my classroom library database work (I am a teacher). The function takes a range and creates new records when one row has a more complex set of data. Here is the Script:
function BreakBorrow(range) {
delimiter = ";"
targetColumn = 1
var output2 = [];
for(var i=0, iLen=range.length; i<iLen; i++) {
var s = range[i][targetColumn].split(delimiter);
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 == targetColumn) {
output1.push(s[j]);
} else {
output1.push(range[i][k]);
}
}
output2.push(output1);
}
}
return output2;
}
For confidentiality reasons, I can't share the database itself, but an example record looks similar to below. In the actual sheet, these are Columns B, C, D, and E — Row A is actually titled "UniqueID". The sheet is called "BooksOut":
The script takes the data in Row A and, if there is a semicolon, splits the result to look like this:
Or it would, if it were working.
I've been using this script for years at this point. Each year I copy the database, including the scripts, and start fresh with new records. Each academic year has its own record of borrows. This is the first year I've had this problem.
A1 in that second image looks like this: =BreakBorrow(BooksOut!A1:E300)
If anyone can help, I'd really appreciate it. I'm not sure what is wrong. I've tried refreshing, removing the script and adding it again, removing the function from the sheet then adding it again, and making nonsense changes, saving, and saving hoping that any of these things my reset to what was working just fine a week ago.
It worked for about 3 minutes when I opened it this morning, then returned to perpetually Loading.
Thanks!