In Excel 365, how can I select non-contiguous columns from a range using a single dynamic array formula? Consider data in columns A:E
as follows:
Entering =XLOOKUP(G1,A1:E1,A2:E11)
into cell G2
returns the column labeled col2
. But =XLOOKUP(G1:I1,A1:E1,A2:E11)
returns the first entry of the those three columns instead of the entire columns. How can I understand this behavior? What's an alternative?
I can similarly retrieve a single column but not a group of columns with INDEX
/XMATCH
or FILTER
:
=INDEX(A2:E11,0,XMATCH(G1,A1:E1))
=FILTER(A2:E11,A1:E1=G1)