## Choose between two data sets to VLOOKUP

*Article last updated on August 10, 2018*

**Question:** How do I search a specific data set, I have two tables to choose from?

**Answer:**

Formula in cell C13:

### Define named ranges

You also need to define the data sets as named ranges.

- Select cell range B4:C9
- Type in the name box the name you want to use. I wrote
*Table1*.

Repeat above steps with the second data set, I named it *Table2*. You may define more named ranges if you like.

### Dataset layout

Make sure that the tables have data arranged the same way, the VLOOKUP function gets the value from column 2 in the example above.

If you don't have the columns arranged in the same way in both tables you will get the wrong value.

### Explaining formula

#### Step 1 - Convert named range to a cell reference

The VLOOKUP function can't evaluate a text string in the formula, however, the INDIRECT function lets you do that.

INDIRECT(C11)

becomes

INDIRECT("Table1")

and returns B4:C9.

Keep in mind that the INDIRECT fiunction is volatile and may slow down your workbook considerably if used extensively.

#### Step 2 - Get the correct value from a given column number based on a lookup value

VLOOKUP(C12,INDIRECT(C11),2,0)

becomes

VLOOKUP(C12,B4:C9,2,0)

becomes

VLOOKUP("bus",B4:C9,2,0)

and returns 2 in cell C13.

### Download Excel *.xlsx file

How to use a Table name in Data Validation Lists and Conditional Formatting formulas

David Hager gave this valuable comment about how to reference a table name in conditional formatting formulas: =INDIRECT("Table1[Start]") Watch this video to […]

Table of contents Initials from first and last names Initials from first, middle and last names Create middle name initials […]

How to use absolute and relative references

What is a reference in Excel? Excel has a A1 reference style. Columns are named letters A to XFD. Total […]

Drop down list changes cell formatting

You can apply different conditional formatting formulas and formatting to a cell range, using a drop down list. Here is […]

Use Conditional Formatting to do lookups in related tables

It can be really hard trying to follow a lookup in related tables. I will show you how to use […]

VLOOKUP with multiple criteria

The VLOOKUP function cell D16 looks for both a value in column B and another value in column C. […]

How to return a value if lookup value is in a range

In this article, I will demonstrate ways to lookup values that is to be found between given ranges and return […]

VLOOKUP of three columns to pull a single record

Question: Does anyone know how to do a VLOOKUP of three columns to pull a single record? Answer: Array formula in […]

Use VLOOKUP to calculate discount percentages

Have you ever tried to build a formula to calculate discounts depending on price? The VLOOKUP function is much easier to […]

How to use the VLOOKUP function

The VLOOKUP function lets you search the leftmost column for a value and return another value on the same row […]

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Use the img tag, like this: <img src="Insert pic link here">

**Contact Oscar**

You can contact me through this contact form