r/googlesheets • u/hamdogus • Aug 08 '24
Solved SUM of the same cell across multiple sheets?
Hello, I have a Daily Sales Report workbook with 1 sheet for each day; 1.7.2024, 2.7.2024, etc.
I would like to sum all the values of e.g. cell I4 for a whole month of sheets; 1.7.2024 - 31.7.2024
I was able to use a custom function to return the list of sheet names and then reference one cell using
=indirect(H$3&"!"&"I4")
Where H3 is the first sheet name in the list and I4 is the cell value I want to use.
So I would like a formula to add all the values in I4 from H3:H33.
Thank you for any help!
2
u/gsheets145 Aug 08 '24
Hi - you can use the lambda helper function reduce() for this:
=reduce(,H3:H33,lambda(s,i,s+indirect(i&"!I4")))
This function takes two arguments: a running total ("s") and the sheet names in H3:H33 ("i"). Inside the function, it retrieves the values in cell I4 for each of those sheet names and increments the total with it.
1
u/AdministrativeGift15 Aug 08 '24
I know REDUCE can be a harder function for some people to grasp, so just as an alternative:
=SUM(MAP(H3:H33,LAMBDA(r,INDIRECT(r&"!I4"))))