I'm trying to work out a formula to sum up values across different sheets for particular rows as in the following:
Sheet 1
A | B
---------
bob | 3
foo | 14
bar | 7
Sheet 2
A | B
---------
bob | 2
foo | 1
bar | 9
But with the caveat that a new 'Sheet 3' can be added with relevant data and will automatically be picked up.
How do I go about getting the summed values for each row in each sheet while handling new (properly named) sheets?
Results
-------
bob | 5
foo | 15
bar | 16
We can assume that the row values are all the same, such as in a named range, People = {bob, foo, bar}.
My attempt has been something like:
={People,ARRAYFORMULA('Sheet 1'!B1:B3+'Sheet 2'!B1:B3)}
but for new sheets, I would have to manually update the formula by adding in
+'Sheet 3'!B1:B3
I've tried using INDIRECT
to dynamically generate the sheet names but it doesn't take an array. I'm guessing that I might have to use
SpreadsheetApp.getActiveSpreadsheet().getSheets()
in a script, but if I could do it just as a formula, it would be easier to explain to people inheriting the spreadsheet.
Thanks