Alan Beban wrote...
....
=IF(ISNA(INDEX(INDEX(Tbl2,ROW(A1),0),1,MATCH($I$2,INDEX(Tbl2,
ROW(A1),0),0)+1)),"",INDEX(INDEX(Tbl2,ROW(A1),0),1,
MATCH($I$2,INDEX(Tbl2,ROW(A1),0),0)+1))
....
The ISNA(INDEX(INDEX(..))) term could be replaced by a more
efficient equivalent check.
COUNTIF(INDEX(Tbl2,ROW(A1),0),$I$2)=0
This formula assumes that there are no duplicate numbers in B,D,F of any
single row of Tbl2. I haven't considered whether it can be readily
modified to deal with duplicates in a single row.
....
Since the data source is a range, it can be dealt with using COUNTIF,
OFFSET and MATCH. If the search should be by row then by group of
columns,
so go down the 1st col, then wrap to the top of the 3rd col, etc., try
the
array formula
=VLOOKUP(I2,OFFSET(Tbl2,0,(MATCH(TRUE,COUNTIF(OFFSET(Tbl2,0,{0,2,4},,1),
I2)>0,0)-1)*2,,2),2,0)
On the other hand, if the search should be by column group then row, so
go
through the column groups on the top row, then wrap to the 1st column
group
on the 2nd row, etc., then this can't be done with a single formula
because
it requires too many levels of nested function calls. However, if the
data
range isn't too large, then it can be done using a defined name like
seq
referring to an expression like
=ROW(INDIRECT("1:1024"))
in an array formula like
=VLOOKUP(I2,OFFSET(Tbl2,0,MOD(MATCH(TRUE,N(OFFSET(Tbl2,INT((seq-1)/3),
MOD(seq-1,3)*2,1,1))=I2,0)-1,3)*2,,2),2,0)
These formulas assume the entries in the 1st, 3rd and 5th cols of Tbl2
are
numbers rather than text. If they're all text, replace the N() calls
with
T() calls. If they're a mix of text and numbers, there's no alternative
to
rearranging the data or using udfs.