Dynamic Index Column in VLOOKUP in Google Sheets

Here is a simple trick you can use to get a dynamic index column in VLOOKUP. You can follow two methods in Google Sheets to achieve this. What are they?

  1. Create a virtual array (VLOOKUP range) and freeze the index column number. In this case, the index column number remains constant. For example, the index column number might always be 2, even if you delete or insert new columns. This brings dynamism to the index column while keeping the same reference.
  2. Use the COLUMN function as the index number. This automatically adjusts the VLOOKUP index column when you delete or add new columns in the range.

Suppose you have a 5-column dataset, and you want to return a value from column 3 based on a lookup in column A. In this case, column 3 is your index column.

Now, what happens when you insert a new column between columns 1 and 2, or between columns 2 and 3? The index column number in your VLOOKUP will still be 3, but it should now be 4 because the column positions have shifted.

You can “freeze” the third column (not the index number itself) in VLOOKUP, regardless of its position or index number. Let me explain this concept, called a dynamic index column in VLOOKUP, in Google Sheets.

Tips to Get a Dynamic Index Column in VLOOKUP in Google Sheets

Sample Data:

Example of a dynamic index column in VLOOKUP

In this example, I want to look up a name in column A to retrieve that person’s date_of_arrival, which is in column C.

In VLOOKUP, the index number for the date_of_arrival column is 3. How can we freeze this index column (not the column number) in Google Sheets?

First, let’s see a standard VLOOKUP formula that returns the date_of_arrival based on the lookup name “Patrick”:

=VLOOKUP("Patrick", A2:E7, 3, FALSE)
Example of a basic VLOOKUP formula in Google Sheets

This formula looks for the name “Patrick” in column A, within the range A2:E7, and returns the value from column 3 (the date_of_arrival) in the corresponding row.

In this formula, the column index is not dynamic. This means if you insert a new column after columns A or B, the index number should now be 4, since the date_of_arrival column has shifted to position 4. However, in the formula, it will still reference 3.

As mentioned earlier, you can freeze the index column (not the column number) in two ways in Google Sheets.

Dynamic Index Column Formulas

Formula 1: Get Dynamic Index Column in VLOOKUP in Google Sheets

=VLOOKUP("Patrick", A2:G7, COLUMNS(A2:C7), FALSE)

Formula 2: Get Dynamic Index Column in VLOOKUP in Google Sheets

=VLOOKUP("Patrick", {A2:A7, C2:E7}, 2, FALSE)

The first formula makes the index number dynamic by using the COLUMNS function. The COLUMNS function counts the columns from A to C and returns the number 3. This number is then used as the column index in the VLOOKUP formula.

When you insert or add new columns between columns A and C, the column index number will change dynamically.

The second formula follows a different approach to create a dynamic index column in VLOOKUP.

In this formula, the column index number remains 2, regardless of the actual column index. This is because the lookup range only includes the first column (the lookup column), followed by the range starting from the index column.

For example, our original data range is A2:E7, but in VLOOKUP, I modified this range to {A2:A7, C2:E7}, effectively skipping the columns between columns A and C.

This way, any changes such as inserting or deleting new columns won’t affect the formula.

Conclusion

The two methods above are the easiest ways to make the index column dynamic in VLOOKUP in Google Sheets.

Of course, you can also use INDEX-MATCH as an alternative, but VLOOKUP remains the simplest and most straightforward option.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

How to Extract Numbers from Text in Excel with Regex

You can use the REGEXEXTRACT or REGEXREPLACE functions to easily extract numbers from text...

Using OFFSET and MATCH Together in Google Sheets: Advanced Tips

One powerful and flexible way to look up values is by combining the OFFSET...

How to Use OFFSET and XMATCH Functions Together in Excel

We often use the OFFSET and XMATCH functions together to match a value in...

How to Calculate Maximum Drawdown in Excel and Google Sheets

You can use the following dynamic array formula to calculate maximum drawdown (MDD) in...

More like this

Using OFFSET and MATCH Together in Google Sheets: Advanced Tips

One powerful and flexible way to look up values is by combining the OFFSET...

Running Count with Structured References in Google Sheets

Running a count with structured references is achievable in Google Sheets tables using the...

Running Total with Structured Table References in Google Sheets

You can use two types of formulas to create a running total with structured...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.