I was trying to answer another question, when I realised that I don't know how to enter an array, consisting of different arrays, as an input parameter for the INDEX()
or the MATCH()
function.
Background:
As some of you know, you can find a value somewhere in an Excel sheet, and use the INDEX(MATCH(...))
trick in order to find adjacent cells.
Simple example:
Id | Value |
---|---|
a | 1 |
b | 5 |
The "Id", corresponding with the maximal value, can be found as:
=OFFSET(INDEX(B2:B3,MATCH(MAX(B2:B3),B2:B3)),,-1)
This is relatively easy, but when the lookup array is spread over multiple columns, this seems not to work:
Id | Value | Rubbish | Id | Value |
---|---|---|---|---|
a | 1 | x | c | 2 |
b | 5 | x | d | 7 |
The lookup array is no longer B2:B3
, but B2:B3,E2:E3
.
That lookup array can be used for the MAX()
function, but when filling in this into the INDEX()
and the MATCH()
function, Excel seems to think that I'm filling in two input parameters, B2:B3
and E2:E3
(because of the comma in between).
So I need a function, let's call it TREAT_AS_ONE_ARRAY()
, so that I can use my formula:
=OFFSET(
INDEX(
TREAT_AS_ONE_ARRAY(B2:B3,E2:E3),
MATCH(MAX(B2:B3,E2:E3),
TREAT_AS_ONE_ARRAY(B2:B3,E2:E3)
)
),,-1)
Does such a function exist?