ExcelFunctions.net

Search Site:

The #REF! error is generally produced when you attempt to access locations that do not exist.

When using the Vlookup function, the Vlookup #REF! error occurs if either:

- the supplied col_index_num is greater than the number of columns in the supplied table_array).

or

- the function refers to cells that do not exist.

The following steps consider both of these problems.

Step 1 - Check the col_index_num argument

First carry out a simple check on the col_index_num argument. This should be a positive integer that is less than or equal to the number of columns in the table_array.

Step 2 - Check for #REF! values in the Formula

If the Vlookup #REF! error is caused by an attempt to reference cells that do not exist, this will show up as one or more #REF! errors in the formula. Therefore, if you look at your Vlookup formula, you will clearly be able to see this.

There are two common reasons why your function may attempt to reference cells that don't exist. One reason is that one (or more) of the function arguments previously referred to cells, which have now been deleted.

Also, this problem frequently arises due to relative references in copied formulas. For example, if you use the mouse to select an entire worksheet (named Sheet1) as the table_array for a Vlookup function, this will be inserted into the Vlookup function as the range **Sheet1!1:1048576** (in Excel 2007 and later versions of Excel).

If this Vlookup function is then copied down a row, the relative referencing within the formula, changes the table_array in the copied formula, to **Sheet1!2:1048577**. However, the row 1048577 doesn't exist, as so this results in the #REF! error being inserted into the copied Vlookup formula instead.

Quick Fix to this Problem: Use Absolute References

The simplest way to prevent a reference to a range from changing when copied to other cells is to use absolute references within the formula.

E.g. the reference **Sheet1!1:1048576** should be changed to **Sheet1!$1:$1048576**.

Note that the $ signs keep this reference constant when the formula is copied to other cells and will therefore avoid the Vlookup #REF! error.

See the Excel Cell References page for more information on cell references.

BETTER Fix to this Problem: Be More Specific When Defining the table_array

Your Vlookup function will be more efficient if the table_array only includes the cells that contain the table_array data, rather than using entire columns, or an entire worksheet.

However, you will still need to use absolute references if you want the table_array to remain constant when the formula is copied to other cells.

Further Vlookup troubleshooting tips are provided, in the form of a handy Vlookup Quick Reference Card, on the Microsoft Office website.