Quick, clean, and to the point

Two-way lookup with VLOOKUP

Excel formula: Two-way lookup with VLOOKUP
Generic formula 


Inside the VLOOKUP function, the column index argument is normally hard-coded as a static number.  However, you can also create a dynamic column index by using the MATCH function to locate the right column. This technique allows you to create a dynamic two-way lookup, matching on both rows and columns. It can also make a VLOOKUP formula more resilient: VLOOKUP can break when columns are inserted or removed from a table, but a formula with VLOOKUP + MATCH can continue to work correctly even changes are made to columns.


In the example, we are using this formula to dynamically lookup both rows and columns with VLOOKUP:


H2 supplies the lookup value for the row, and H3 supplies the lookup value for the column.

How this formula works

This is a standard VLOOKUP exact match formula with one exception: the column index is supplied by the MATCH function.

Note that the lookup array given to MATCH (B2:E2) representing column headers deliberately includes the empty cell B2. This is done so that the number returned by MATCH is in sync with the table used by VLOOKUP. In other words, you need to give MATCH a range that spans the same number of columns VLOOKUP is using in the table. In the example (for Feb) MATCH returns 3, so after MATCH runs, the VLOOKUP formula looks like this:


Which returns sales for Colby (row 4) in Feb (column 3), which is $6,786.

Dave Bruns

Excel Formula Training

Formulas are the key to getting work done in Excel. In this step-by-step training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Start building valuable skills with Excel formulas today. Learn more.

I thoroughly enjoy watching the videos you provide on your website...Your videos make learning featres in Excel easier than reading instructions. Being able to see something demonstrated makes all the difference. -NG
Excel foundational video course
Excel Pivot Table video training course
Excel formulas and functions video training course
Excel Shortcuts Video Course
Excel Charts video training course