mountainman88
Board Regular
- Joined
- Jun 22, 2019
- Messages
- 109
- Office Version
- 2016
- Platform
- Windows
I would like some code to create a UDF which works as follows:
The UDF has one argument which is a range, the range can be any size and each cell in the range must contain a valid tab name in the same workbook (tab names may have spaces). The UDF then adds together the cells on each tab in the range with the same cell reference the UDF is entered into.
For example lets call the UDF SUMTAB. The SUMTAB UDF is entered into cell B3 as below, and the range argument contains 4 tab names (tab1, tab2 etc). The output would be the sum of cell b3 on tabs1-4.
I would also like a 2nd version of the UDF called SUMTABRNG with an extra argument where the cell range that is summed can be specified:
See below the 1st argument is now a range a1:b3, this range will be what is summed across all tabs in the 2nd argument
Thanks in advance!
The UDF has one argument which is a range, the range can be any size and each cell in the range must contain a valid tab name in the same workbook (tab names may have spaces). The UDF then adds together the cells on each tab in the range with the same cell reference the UDF is entered into.
For example lets call the UDF SUMTAB. The SUMTAB UDF is entered into cell B3 as below, and the range argument contains 4 tab names (tab1, tab2 etc). The output would be the sum of cell b3 on tabs1-4.
Book3 | ||||
---|---|---|---|---|
A | B | |||
1 | ||||
2 | ||||
3 | =SUMTAB(A5:A8) | |||
4 | ||||
5 | tab1 | |||
6 | tab2 | |||
7 | tab3 | |||
8 | tab4 | |||
UDF |
I would also like a 2nd version of the UDF called SUMTABRNG with an extra argument where the cell range that is summed can be specified:
See below the 1st argument is now a range a1:b3, this range will be what is summed across all tabs in the 2nd argument
Book3 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | |||||
2 | |||||
3 | =SUMTABRNG("a1:b3",A5:A8) | ||||
4 | |||||
5 | tab1 | ||||
6 | tab2 | ||||
7 | tab3 | ||||
8 | tab4 | ||||
UDF |
Thanks in advance!