View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove[_2_] Harlan Grove[_2_] is offline
external usenet poster
 
Posts: 1,231
Default Array formula that works columnwise?

Jerry W. Lewis wrote...
I have not found a solution yet, but I have found another
inconsistency in the processing of array formulas.

If you array enter

=MAX(INDEX(IF(ISNUMBER(A1:D5),A1:D5),,COLUMN(A1:D 1)))
-MIN(INDEX(IF(ISNUMBER(A1:D5),A1:D5),,COLUMN(A1:D1) ))

in a 1x4 range of cells, you get the four columnwise max-min's, but

=COUNT(MAX(INDEX(IF(ISNUMBER(A1:D5),A1:D5),,COLUM N(A1:D1)))
-MIN(INDEX(IF(ISNUMBER(A1:D5),A1:D5),,COLUMN(A1:D1) )))

only returns 1, and


These results arise from the INDEX calls, which return arrays of
arrays. Excel copes with this return type the same way it does with
arrays of range references (e.g., INDEX(A1:D5,0,{1,2})) - by using
implicit indexing when entered into multiple cell ranges.

=MAX(MAX(INDEX(IF(ISNUMBER(A1:D5),A1:D5),,COLUMN( A1:D1)))
-MIN(INDEX(IF(ISNUMBER(A1:D5),A1:D5),,COLUMN(A1:D1) )))

returns the first value, instead of the largest of the 4 values that
were returned by the original array formula.


Enter your last formula into a 1x4 cell range and you'll get the same
result as your first formula above. Why? Because Excel applies the
outer MAX function to each, er, subarray returned by its argument, and
each of those is a degenerate array with a single value.

I know what I believe, but do you believe anyone on the Excel
development team could explain these semantics? They've certainly
never bothered to provide any documentation about them.