Sum() Across Dynamic Number of Sheets

青春壹個敷衍的年華 提交于 2019-12-04 14:52:18

Here's another approach:

Assuming that your user's data entry sheets are labelled according to some kind of system that has to be strictly adhered to (e.g. "Data entry 1", "Data entry 2", etc.), you could build a summary table using INDIRECT - and then total this table instead.

In detail, you'd have a helper table in your 'Totals' sheet, looking something like this:

   Col A         Col B    Col C    Col D
1                         C5       X7
2  Sheet name    Exists?  Value 1  Value 2
3  Data entry 1  TRUE          10       20
4  Data entry 2  FALSE          0        0
5  Data entry 3  TRUE          20       30
6  ...
.
.
.
20 More sheet names than you'll ever get just to be sure!
  • In cells C1 and the following columns you'd write the address of the cell you want to total. If you have a template and want to keep the references dynamic (usually the static nature of the address is a source of bugs here), use =ADDRESS(ROW(Template!C5);COLUMN(Template!C5)) to get the dynamic address.
  • In column B you'd use this formula: =NOT(ISERROR(INDIRECT(ADDRESS(1,1,,,A3))))
  • In column C and the following columns, use this: =IF(B3,INDIRECT("'"&A3&"'!"&C$1),0)

Now you only need to total the columns C and so forth.

Good news! You can make your life much simpler - by using a 3D formula:

If you use this formula: =SUM(Sheet1:Sheet3!$A$1:$B$2), all cells in A1:B2 will be summed - across all sheet from Sheet1 to Sheet3!

Quite often, it is helpful to use two "helper" sheets to handle an open/changing number of worksheets:

  1. Insert two worksheet called START and END
  2. Span your 3D formula across those two sheets
  3. Move all the sheets between or move START and END sheet around those sheets (of course, this can be done in step 1, too)
  4. Hide the two helper sheets

Check out this link for further instructions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!