Summary

To look up and retrieve an entire column, you can use a formula based on the XLOOKUP function. In the example shown, the formula in cell H5  is:

=XLOOKUP(H4,quarter,data)

where quarter (C4:F4) and data (C5:F16) are named ranges. With a lookup value of "Q3" in cell H4, the result is all values associated with Q3, which spill into the range H5:H16.

Note: this problem can also be solved with INDEX and MATCH and FILTER, as described below.

Generic formula

=XLOOKUP(value,header,data)

Explanation 

In this example, the goal is to look up and retrieve an entire column of values in a set of data. For example, when a value like "Q3" is entered into cell H4, all values in the range E5:E16 should be returned. For convenience and readability, quarter (C4:F4) and data (C5:F16) are named ranges.

Although this example shows off the simplicity of the XLOOKUP function, it can also be solved with a straightforward INDEX and MATCH formula, as described below.

With XLOOKUP

With the XLOOKUP function, the solution is straightforward. In the example shown, the formula in H5 is:

=XLOOKUP(H4,quarter,data)

Here, lookup_value is H4 (which contains "Q3"), lookup_array is quarter (C4:F4), and return_array is data (C5:F16). With this configuration, XLOOKUP matches the 3rd value in C4:F4, and returns the third column in C5:F16. In the dynamic array version of Excel, the 12 values in E5:E16 spill into the range H5:H16. If the value in H4 is changed to a different quarter, the formula will immediately recalculate and return a new column of values.

With FILTER

You might not think of using the FILTER function to filter columns, but it works fine. In this case, the formula to solve this problem is:

=FILTER(data,quarter=H4)

After the include argument is evaluated, we have an array of TRUE and FALSE values:

=FILTER(data,{FALSE,FALSE,TRUE,FALSE})

And FILTER returns the third column in data. For another example of using FILTER on horizontal data, see this page.

With INDEX and MATCH

This problem can also be solved with an INDEX and MATCH formula like this:

=INDEX(data,0,MATCH(N4,quarter,0))

The gist of the solution is that the MATCH function is used to identify the column index, and the INDEX function will retrieve the entire column when row_num is set to zero(0). Working from the inside out, MATCH is used to get the column index like this:

MATCH(H4,quarter,0) // returns 3

With "Q3" in H4, the MATCH function returns 3, since "Q3" is the third value in quarter (C4:F4). MATCH returns this result directly to the INDEX function as the col_num argument, with array set to data, and row_num set to 0:

=INDEX(data,0,3)

This causes INDEX to return all 12 values in the third column of data as a final result. In the dynamic array version of Excel, these results will spill into the range H5:H16. In Legacy Excel, you will need to enter this formula as a multi-cell array formula.

Processing with other functions

Often, the purpose of looking up and retrieving an entire column of values is to feed those values into another function like SUM, MAX, MIN, AVERAGE, LARGE, etc. This is simply a matter of nesting the lookup formula into another function. For example,  you can get the sum, max, and average for Q3 like this:

=SUM(XLOOKUP(H4,quarter,data)) // get sum
=MAX(XLOOKUP(H4,quarter,data)) // get max
=AVERAGE(XLOOKUP(H4,quarter,data)) // get average

In each formula, the XLOOKUP returns all 12 values in the Q3 column to the outer function, which returns a single result. The same approach can be used with the INDEX and MATCH and FILTER versions of the formula.

Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.