Search code examples
arraysexcelexcel-formula

Finding a value in an Excel array


I have to imagine the answer is somewhere but I am not sure where.

Here is the situation: I have a 6-column array of numbers starting from zero, and they increment sequentially, but not in every cell, nor in every row. If a value in, say, the third column is the same as in the second, then the fourth (and therefore the fifth and sixth) would not change. I want to be able to look up a number by finding the first instance of the array, going from left to right and then down the array, and then returning a number in a parallel array to the right of this one.

enter image description here

I tried using a combination of XLOOKUP and INDIRECT functions, such as (for example, finding 1):

=INDIRECT(ADDRESS(ROW(XLOOKUP(1,A:A,A:A,XLOOKUP(1,B:B,B:B,XLOOKUP(....))),COLUMN(XLOOKUP....)+8)), with the +8 representing another array 8 columns to the right, where the value I am looking up is to be found.

It almost works, but in cases such as 4, where the number first appears in the third column, remains constant for the rest of the row, and then does not change in the following row, nothing gets returned.

I have to imagine the answer is simple - any help would be great.


Solution

  • With arranging in one row the arrays and INDEX and MATCH functions

    =INDEX(TOROW(OFFSET(A1:F7,0,8)),,MATCH(E11,TOROW(A1:F7),0))

    enter image description here