I have a requirement to count if a cell's value in C8:C23 on the third through last sheet in workbook is "vacant". I never know how many sheets there will be.
Currently the formula below works, where SheetList is a named range containing the names of the worksheets. SheetList is somewhat dynamic as the size of the range is set by a macro when the worksheets are created. The sheet names are always as follows
1450-1, 1450-1 (2), 1450-1 (3), etc. I created a list on a hidden sheet of 1450-1 - 1450-1 (100), which there will never be a sheet higher than. SheetList will then refer to HiddenSheet!A1:A(#of 1450-1 sheets).
=SUMPRODUCT(COUNTIF(INDIRECT("'"&SheetList&"'!C8:C23"),"Vacant"))
I can no longer have hidden sheets. The number of sheets, once created, will never change. I have the following line of code to make a formula elsewhere in the sheet
Worksheets("1450").Range("I13").Formula = "=SUM('1450-1:1450-1 (" & t & ")'!E24)"
t = the number of 1450-1 sheets.
When I tried to use the same concept for the SUMPRODUCT formula it did not work:
=SUMPRODUCT(COUNTIF(INDIRECT('1450-1:1450-1 (20)'!C8:C23),"Vacant"))
I cannot use MoreFunc, named ranges (unless they are refering to C8:C23, but not a hidden named range like SheetList above), and the formulas must remain live.
If you have any suggestions on how to solve this problem, please let me know.
Thanks,
Bill
Currently the formula below works, where SheetList is a named range containing the names of the worksheets. SheetList is somewhat dynamic as the size of the range is set by a macro when the worksheets are created. The sheet names are always as follows
1450-1, 1450-1 (2), 1450-1 (3), etc. I created a list on a hidden sheet of 1450-1 - 1450-1 (100), which there will never be a sheet higher than. SheetList will then refer to HiddenSheet!A1:A(#of 1450-1 sheets).
=SUMPRODUCT(COUNTIF(INDIRECT("'"&SheetList&"'!C8:C23"),"Vacant"))
I can no longer have hidden sheets. The number of sheets, once created, will never change. I have the following line of code to make a formula elsewhere in the sheet
Worksheets("1450").Range("I13").Formula = "=SUM('1450-1:1450-1 (" & t & ")'!E24)"
t = the number of 1450-1 sheets.
When I tried to use the same concept for the SUMPRODUCT formula it did not work:
=SUMPRODUCT(COUNTIF(INDIRECT('1450-1:1450-1 (20)'!C8:C23),"Vacant"))
I cannot use MoreFunc, named ranges (unless they are refering to C8:C23, but not a hidden named range like SheetList above), and the formulas must remain live.
If you have any suggestions on how to solve this problem, please let me know.
Thanks,
Bill