|
Question : Wildcards in worksheet names/SUMPRODUCT range
|
|
I teach at secondary school. I have 2+ worksheets called 7M, 7T, etc. with data on students in my school in them (e.g. 7M = Year 7 Form M).
I am needing to count all those who are Male ("M") and who have answered "Yes" to a question.
My present formula is in the form:
=SUMPRODUCT(('7M'!M1:M500="M")*('7M'!N1:N500="Yes"))+SUMPRODUCT(('7T'!M1:M500="M")*('7T'!N1:N500="Yes"))
I would like to be able to put something like the following:
=SUMPRODUCT(('7*'!M1:M500="M")*('7M'!N1:N500="Yes"))
or even better:
=SUMPRODUCT(('REF TO ANOTHER CELL CONTAINING THE CLASS YEAR GROUP*'!M1:M500="M")*('REF TO ANOTHER CELL CONTAINING THE CLASS YEAR GROUP*'!N1:N500="Yes"))
|
|
Answer : Wildcards in worksheet names/SUMPRODUCT range
|
|
Again, if you didn't wish to use column A (rows 1 to 3, or beyond) to store the list of forms, enter the following directly into cell A1:
=SUMPRODUCT((INDIRECT("'"&CHOOSE(ROW(),"7M","7T","7S")&"'!M1:M500")="M")*(INDIRECT("'"&CHOOSE(ROW(),"7M","7T","7S")&"'!N1:N500")="Yes"))
and then copy down to cells A2 & A3.
If you wished to extend the list to more forms (than 7M, 7T & 7S) make sure you change both references to this list within the formula.
e.g. To add forms 7X, & 7Z [typed as one line into an Excel cell]:
=SUMPRODUCT((INDIRECT("'"&CHOOSE(ROW(),"7M","7T","7S","7X","7Z")&"'!M1:M500")="M")* (INDIRECT("'"&CHOOSE(ROW(),"7M","7T","7S","7X","7Z")&"'!N1:N500")="Yes"))
BFN,
fp.
|
|
|
|