I did a ton of searching for this problem, and I think the problem is that all the answers lead to a solution that requires creating a library. Then the only way to add this library to the spreadsheet is to create a new script for this table and enable it.
What I want: A bunch of spreadsheets in which everyone includes one script wizard. Each time the script is updated, they are all updated to use the latest script.
What I have: 15 spreadsheets that have copies of the original script. The original script has changed, and now it seems to me that I need to change every script called Copy of myScriptNamethat exists in every copied spreadsheet.
What I did: I created the first table and wrote a script from a project created in its script editor. Worked great. Then I made 14 copies of this table for each division of the company to use.
How can I just share the script and manage it outside of any of the individual spreadsheets? I need to miss something, considering all the people who are looking for the same answer. I just don't see how the library library solves my use case.
Thank!
I don’t see that this will help, but in the comment request there is a script here:
function createRollupTable() {
if(arguments.length <= 1 || !arguments[0] || arguments[0].length <= 0) {
return "";
}
var rollupTable = new Array();
var fullListAccountCodes = arguments[0];
rollupTable[0] = fullListAccountCodes;
var yearlyAccountCostOutput = new Array(fullListAccountCodes.length);
for(var i=1;i<arguments.length;i++) {
var quarterlyRollupCostOutput = new Array(fullListAccountCodes.length);
var quarterlyBreakdown = arguments[i];
var quarterIndexCounter = 0;
var quarterTotalCost = 0;
for(var j=0;j<fullListAccountCodes.length && quarterIndexCounter<quarterlyBreakdown.length;j++) {
if(fullListAccountCodes[j] == quarterlyBreakdown[quarterIndexCounter][0]) {
quarterlyRollupCostOutput[j] = quarterlyBreakdown[quarterIndexCounter][1];
quarterTotalCost += quarterlyBreakdown[quarterIndexCounter][1];
if(yearlyAccountCostOutput[j]) {
yearlyAccountCostOutput[j] += quarterlyBreakdown[quarterIndexCounter][1];
} else {
yearlyAccountCostOutput[j] = quarterlyBreakdown[quarterIndexCounter][1];
}
quarterIndexCounter++;
}
}
rollupTable[i] = quarterlyRollupCostOutput;
rollupTable[i].push("");
rollupTable[i].push(quarterTotalCost);
}
rollupTable[0].push("");
var spaces = "";
var numSpaces = 66;
for(var i=0;i<numSpaces;i++){spaces+=String.fromCharCode(160);};
rollupTable[0].push(spaces + "Totals:");
rollupTable.push(yearlyAccountCostOutput);
return rollupTable;
}
source
share