There are two cost tables in the worksheet, one for Vendor A and one for Vendor B.

Both tables are defined as thenamed rangesvendor_a(B5:C8) andvendor_b(B11:C14).

However, the formula below will fail with a #VALUE!

Excel formula: INDEX with variable array

error:

Why is that?

The formula above messes up thanks to Excel interprets the table as atext value, not arange.

What we need is a way to tell Excel to interpret the text value like a cell reference.

Excel formula: Dynamic reference to table

This is a job for theINDIRECT functionwhich is designed to evaluate a text value as a reference.

If the vendor is changed to “b”, VLOOKUP will dynamically switch tables and return $12.50.

It also nicely demonstrates how one function can benestedinside another to deliver a range instead of a single value.

Excel formula: VLOOKUP without #N/A error

INDIRECT is useful when you want to assemble a text value that can be used as a valid reference.

More than one condition can be tested by nesting IF functions.

The IF…

How to use VLOOKUP

Excel formula: Lookup with variable sheet name

Excel formula: VLOOKUP two-way lookup

Excel formula: VLOOKUP calculate grades

Excel INDIRECT function

Excel VLOOKUP function

Excel IF function

Article image