Not at all. Happy to explain.
It's pretty much similar, apart from the fact that we now have this part:
CELL("address",B2)
which simply returns a text representation of a cell reference. Here, The above will resolve to $B$2.
Unlike in the previous formula I gave you, however, in which this value was fixed, here it is dynamically dependent upon the row in which the formula is placed.
Hence, as it is copied down to successive rows, the above will become:
CELL("address",B3) (=$B$3)
CELL("address",B4) (=$B$4)
...
etc.
Hence:
SUMPRODUCT(COUNTIF(INDIRECT("'"&$G$2:$G$4&"'!"&CELL("address",B2)),2))
becomes:
SUMPRODUCT(COUNTIF(INDIRECT("'"&$G$2:$G$4&"'!"&"$B$2"),2))
and I explained how this was resolved in my previous post.
The only other addition was to satisfy your criterion of returning a blank instead of a zero. The standard way to do this would be to use a simple IF statement and repeat the main clause, i.e.:
=IF(SUMPRODUCT(COUNTIF(INDIRECT("'"&$G$2:$G$4&"'!"&CELL("address",B2)),2))=0,"",SUMPRODUCT(COUNTIF(INDIRECT("'"&$G$2:$G$4&"'!"&CELL("address",B2)),2)))
which is perfectly fine, and if this makes things easier for you to understand I would suggest you use this version instead.
The set-up I used simply employs a technique to shorten the formula, which takes advantage of the fact that the only number which results in an error when reciprocated with 1 is zero, so that, if the part:
SUMPRODUCT(COUNTIF(INDIRECT("'"&$G$2:$G$4&"'!"&CELL("address",B2)),2))
is equal to zero, then we will have:
=IFERROR(1/(1/(0)),"")
which is:
=IFERROR(1/(#DIV/0!),"")
i.e.:
=IFERROR(#DIV/0!,"")
(1 divided by #DIV/0! is still #DIV/0!)
which of course resolves to "", i.e. a blank.
If the main SUMPRODUCT part does
not resolve to zero, but e.g. 2, then we will have:
=IFERROR(1/(1/(2)),"")
which is:
=IFERROR(1/(0.5),"")
i.e.:
=IFERROR(2,"")
and clearly 2 is not an error so this returns 2.
This is the reason for the "double-reciprocation": errors remain errors; non-errors are "re-reciprocated" back to their original values.
See here for more on this technique:
http://excelxor.com/2014/08/29/iferr...-from-results/
Regards
Bookmarks