This could be solved without VBA by the following technique.
In this example I am counting all the threes (3) in the range A:A
of the sheets Page M904
, Page M905
and Page M906
.
List all the sheet names in a single continuous range like in the following example. Here listed in the range D3:D5
.
Then by having the lookup value in cell B2
, the result can be found in cell B4
by using the following formula:
=SUMPRODUCT(COUNTIF(INDIRECT("'"&D3:D5&"'!A:A"), B2))