FLKulchar said:
Boy...do I need help with this formula.
For example, what does the following mean:
=SUMPRODUCT (0+ISNA(MATCH(A1:A10,{2,4},0)),A1:A10)
I know it means to add the column of numbers omitting
those that are 2 or 4..
but HOW DOES THIS "MAGICAL" SUMPRODUCT formula WORK??
Thanks,
Larry
As usual, it is easiest to work from the middle outwards.
MATCH(A1:A10,{2,4},0) looks for exact matches between each of the the cells
A1:A10 in turn and the array {2,4}. It produces an array of 10 answers. The
first says if there is a match between A1 and the array {2,4}. If a match is
found, the answer is the position of the match in the array (i.e. 1 if the
match is with 2, or 2 if the match is with 4). If no match is found the
answer is #N/A. Similarly for A2:A10. The important point is that the array
of 10 answers has a number where a match is found and #N/A otherwise.
This array is passed to ISNA, which simply converts #N/A to TRUE and numbers
to FALSE. So we now have an array of 10 boolean values where 'matches' are
indicated by FALSE.
Adding 0 to (each element of) this array is simply a way of converting TRUE
to 1 and FALSE to 0. Another way would have been to multiply the array by 1.
So we now have an array of 10 ones or zeros where 'matches' are indicated by
zero.
SUMPRODUCT then multiplies each element of this array with each of A1:A10
and sums the results. Hence we end up with the sum of A1:A10 but excluding
2's or 4's.