Excel Tutorial
Excel tutorials, quizzes & AI guides — all levels
RSS
  • Online Excel Exercises
  • Training
  • Excel Tests
  • Sitemap
  • Premium Quizzes
  • Shop
  • My account

Create a Dynamic VLOOKUP function

Lookup functions
Reading time: 2 minutes
Views: 13,261

How to build a Dynamic VLOOKUP with the MATCH function?

  • The challenge with the VLOOKUP function is to specify the column number from which you want to return data.
  • The idea is to replace this argument with the MATCH function
  • Like that, we will have a Dynamic VLOOKUP function

The third argument of VLOOKUP returns the column

Let’s consider a scenario where you have created a VLOOKUP function to return the State name based on the Employee ID.

VLOOKUP functions returns the State name
  • We search for the ID in cell C14
  • Our reference table is the Table tbl_Employee (A1:G12)
  • We want to return the 6th column (the State Name column)
  • Finally, 0 to perform an Exact Match

The result is correct. But if we want to return the employee’s name instead, we must manually change the third argument of the VLOOKUP function from 6 to 2.

This is why it’s more efficient to create a dynamic VLOOKUP, where the column index is linked to a dropdown list 😉

Dynamic Vlookup to retunr any column

How to create a Dynamic VLOOKUP

So, the idea is to replace the third argument with a MATCH function.

  • The MATCH function returns the position of an item in a list.
    • First argument: The text to search
    • Second argument: The array where to search the first argument
    • Third argument: The match mode (exact in this situation)

For instance, to return Wednesday’s position in the list of weekdays, we will write the following formula:

Match function to return the position of a day

In our scenario, we will use the MATCH function to find the position of a title column in the headers.

Position of the City column in the reference table

Then, we replace the third argument inside the original VLOOKUP function with the MATCH function, and the job is done.

The third argument is replaced by the match function

Add a dropdown list to select the column header.

The easiest way to select any column header is to build a dropdown list. Then you just have to select one of them to return the result for this column.

Add a dropdown list to select the column header

Frédéric LE GUEN

Dynamic function, MATCH, VLOOKUP

1 Comment

  1. Sein Hla Maung
    17/06/2018 @ 05:02

    Hi,

    Thank for your exercise file.

    Best Regards

    Sein Hla Maung

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Viewed Posts

  • Displaying Negative Numbers in Parentheses in Excel (310,065)
  • Top 10 Excel Functions You Must Know (232,001)
  • How to make automatic calendar in Excel (212,775)
  • Dash for a zero in Excel automatically (190,812)
  • Converting a Date from YYYYMMDD to DD/MM/YYYY in Excel (171,033)
image excel exercises
Excel Exercises
image excel quizzes
Excel Quizzes

Create a Dynamic VLOOKUP function

Reading time: 2 minutes
Views: 13,261

How to build a Dynamic VLOOKUP with the MATCH function?

  • The challenge with the VLOOKUP function is to specify the column number from which you want to return data.
  • The idea is to replace this argument with the MATCH function
  • Like that, we will have a Dynamic VLOOKUP function

The third argument of VLOOKUP returns the column

Let’s consider a scenario where you have created a VLOOKUP function to return the State name based on the Employee ID.

VLOOKUP functions returns the State name
  • We search for the ID in cell C14
  • Our reference table is the Table tbl_Employee (A1:G12)
  • We want to return the 6th column (the State Name column)
  • Finally, 0 to perform an Exact Match

The result is correct. But if we want to return the employee’s name instead, we must manually change the third argument of the VLOOKUP function from 6 to 2.

This is why it’s more efficient to create a dynamic VLOOKUP, where the column index is linked to a dropdown list 😉

Dynamic Vlookup to retunr any column

How to create a Dynamic VLOOKUP

So, the idea is to replace the third argument with a MATCH function.

  • The MATCH function returns the position of an item in a list.
    • First argument: The text to search
    • Second argument: The array where to search the first argument
    • Third argument: The match mode (exact in this situation)

For instance, to return Wednesday’s position in the list of weekdays, we will write the following formula:

Match function to return the position of a day

In our scenario, we will use the MATCH function to find the position of a title column in the headers.

Position of the City column in the reference table

Then, we replace the third argument inside the original VLOOKUP function with the MATCH function, and the job is done.

The third argument is replaced by the match function

Add a dropdown list to select the column header.

The easiest way to select any column header is to build a dropdown list. Then you just have to select one of them to return the result for this column.

Add a dropdown list to select the column header
Tags: Dynamic functionMATCHVLOOKUP

Frédéric LE GUEN

1 Comment

  1. Sein Hla Maung
    17/06/2018 @ 05:02

    Hi,

    Thank for your exercise file.

    Best Regards

    Sein Hla Maung

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Contact us
About me 
Privacy Policy

© 2022 – 2026 – excel-tutorial.com. All Rights Reserved.
Excel Tutorial is managed by majordome du net

Contact us
About me 
Privacy Policy

© 2022 – 2026 – excel-tutorial.com. All Rights Reserved.
Excel Tutorial is managed by majordome du net