I have a spreadsheet that may have any number of sheets on it at any given time. These "Side Sheets" have a total value added and placed in a specified cell. We'll say this total is in cell "A1" on every side sheet. I want to total all of these side sheet totals, and place the total in-cell on another sheet.
I've coded a solution I think should work, but it displays "loading" forever. I'm certain there's an easier way to do this, I just can't see it.
function GETSIDESHEETTOTALS(){
var totalCell = "A1"
var total = 0;
var cur_ss = SpreadsheetApp.getActive();
cur_ss.getSheets().forEach(function(sheet){
total += sheet.getRange(totalCell).getValue();
});
return total;
}
I'm expecting the totals from each sheet to add together and display in the cell I've specified on the main sheet. I've placed the function "=GETSIDESHEETTOTALS()"
into a cell on the main page of my spreadsheet. I would prefer it to be a cell-called function if possible.
Does anyone have an alternate solution, or can tell me what I'm doing wrong?