Sep 21 2021 04:55 PM
Not sure if I am trying something that is impossible? I have a timesheet tracking workbook. Each sheet's name changes dynamically to a job number, when I enter the job number into a cell at the top of each individual sheet.
Example below... update cell E2 to "MJN Job 3" the sheet is automatically named "MJN Job 3"
Currently I have 10 sheets in my work book. We have grown past this, and some weeks we have well over 10 jobs. I want to make a Macro to add sheets. That part is easy. However, all the sheets total on one summary sheet. My current code in the summary sheet is simple...(example above) ='test test'!D42+'MJN 21MJNtest'!D42+'MJN Job 3'!D42... etc.
Can I, or is it possible to have a formula that would know to grab/add all of Cell D42's, from what ever sheets are between let's say sheet "MJN Job 1", and sheet "MJN Job 100"... depending how many sheets I may add?
Sep 21 2021 05:35 PM - edited Sep 21 2021 05:47 PM
SolutionAdd the sum formula into the desired cell
Considering the names you gave us, your formula will look like that
=SUM('test test:MJN Job 3'!D42)
In other words
=SUM('FirstSheet:LastSheet'!D42)
Replace FirstSheet and LastSheet with the worksheet names you wish to sum between.
We can change this to be more dynamic, making it even easier to use. Instead of using the names of the first and last sheets, you can create two blank sheets to act as bookends for your calculation.
Sep 22 2021 05:19 AM
Dec 05 2023 07:06 AM
Jul 10 2024 03:48 AM - edited Jul 10 2024 05:33 AM
@Juliano-Petrukio
Hi Juliano,
Imagine that you have 2 cells, where the first contain the name of the first tab and the second the name of the second one. It can be use full if the tab name change and you have a lot of cells where you use the formula, as if you create a template.
Is it possible to write a formula which use these two cells? It seems that it does not work.
I tried the below formulas:
=SUM(INDIRECT("'"&$A$1 & ":" & $B$2 & "'!D42"))
=SUM(CONCATENATE("'",$A$1,":",$A$2,"'!D42"))
SUM(CONCATENATE("'",$A$1,":",$B$2)&INDIRECT("'!D42"))
No of these formulas works.
Do you have an idea about how to do?
Thank you so much
Jul 10 2024 09:48 AM
INDIRECT() doesn't work with 3D references, i.e. with ones like Shee2:Sheet6. One of workarounds if you have sequentially numbered sheets. When you may generate array of references on such sheets and sum result
=SUM(INDIRECT("Sheet" & SEQUENCE(5,,2) & "!D42" ))
However, that's not practical, especially for the templates.
Another workaround is to create two empty sheets, start and end, we may hide them. Actual sheets will be in between. With that formula could be
=SUM(start:end!D42)
Also not perfect, but at least something.
Another way is to generate list of all sheets with VBA or Automate and use them as in first case.
Jul 11 2024 02:20 AM
Thank you Sergei,
About the first formula, unfortunately, I do not have any sequential sheet names, but it is a solution which could be necessary to keep in mind for any future spreadsheet.
The second solution is good, if we hid the sheets, it will as if there was nothing, then it will be complitely transparent for the users.
Thank you for your answer, whichh was very useful.
Jul 11 2024 02:32 AM
@Boulawan , you are welcome.
Problem with second solution is if user would like to add another tab, most probably it'll be after end. When formula result is incorrect.
Sep 21 2021 05:35 PM - edited Sep 21 2021 05:47 PM
SolutionAdd the sum formula into the desired cell
Considering the names you gave us, your formula will look like that
=SUM('test test:MJN Job 3'!D42)
In other words
=SUM('FirstSheet:LastSheet'!D42)
Replace FirstSheet and LastSheet with the worksheet names you wish to sum between.
We can change this to be more dynamic, making it even easier to use. Instead of using the names of the first and last sheets, you can create two blank sheets to act as bookends for your calculation.