I don't believe that there is a reference Joe, it is learnt behaviour by
seeing what others come up with, and playing with it to see where you can
take it. I may be wrong, but I doubt that anyone (even at MS) understands
the formula code in enough depth to be able to predict how they can be
extended, but we find out by playing, by saying ' ... what if I did this?'.
For instance, look at how we use SUMPRODUCT nowadays. Nowhere in any MS
documentation that I have seen is that mentioned, although I would venture
that by virtue of the promotion of these techniques by the likes of Peo
Sjoblom, Domenic, (the late) Frank Kabel, Toppers, Biff, and dare I say,
myself, the technique is now ubiquitous.
I tried something the other day when I gave a formula to count the most
frequent occurrences of a text value in a range,
=INDEX(rng,MODE(MATCH(rng,rng,0))). It worked fine with a full range, but
failed on a sparse range. By recalling a common solution to counting unique
values in a range, =SUMPRODUCT((rng<>"")/COUNTIF(rng,rng&"")), I was able to
amend the formula to cater for sparse range,
=INDEX(rng,MODE(MATCH(rng&"",rng&"",0))). Experience, like most good things
in life it has to be worked at and earned.
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
I said:
Bob Phillips wrote:
Maybe this is what you want
=SUM(SUMIF(INDIRECT({"B6:B19","B27:B40","H6:H19"}),"My
Product",INDIRECT({"C6:C19","C27:C40","I6:I19"})))/
SUM(COUNTIF(INDIRECT({"B6:B19","B27:B40","H6:H19"}),"My Product"))
[....]
Why do we need the extra SUM(....) around SUMIF and COUNTIF?
Let me take a stab at answering my own question. SUMIF seems to be a
variant-type function, and the INDIRECT list seems to cause SUMIF to
return an array of 3 sums. This is evident when we select 3 columns
and enter SUMIF as an array formula (ctrl-shift-Enter). Thus, SUM is
needed to add the elements of the array of SUMIF results.
This is not be self-evident to me, based on the MS help text. Can
anyone point to a(n MS) reference that explains that behavior?
Moreover, it is not obvious to me that INDIRECT can be used to
construct an array of noncontiguous ranges. Can anyone point to a(n
MS) reference that explains that, too?
I mean: how do people learn of these gems? It is difficult to keep
track of them as they are demonstrated one by one on occassion in
forums like this. It would be nice to find a single reference that
explains these Excel behaviors canonically -- the "K&R" of Excel.