VLOOKUP Evaluates to an Out of Bounds Range in Sheets
Sheets returns #REF! with "VLOOKUP evaluates to an out of bounds range" when the index is wider than the lookup range. Count from the range's first column.
On this page
Google Sheets just returned #REF!, and the message is “VLOOKUP evaluates to an out of bounds range.” The third argument is asking for a column that does not exist inside the lookup range.
Here is a product list in D1:H7. Columns A through C are empty on purpose, because that is how the column count usually goes wrong.
| Row | D (SKU) | E (Product) | F (Category) | G (Price) | H (Stock) |
|---|---|---|---|---|---|
| 1 | SKU | Product | Category | Price | Stock |
| 2 | SKU-101 | Wireless Mouse | Accessories | 24.99 | 85 |
| 3 | SKU-102 | USB-C Hub | Accessories | 39.5 | 42 |
| 4 | SKU-103 | Desk Lamp | Lighting | 32 | 28 |
| 5 | SKU-104 | Laptop Stand | Office | 45 | 63 |
| 6 | SKU-105 | Mechanical Keyboard | Accessories | 89 | 17 |
| 7 | SKU-106 | Monitor Arm | Office | 119 | 24 |
This formula in J2 asks for column 7 from that table:
=VLOOKUP("SKU-104",D2:H7,7,FALSE)
It returns #REF! with that out-of-bounds message. COLUMNS(D2:H7) returns 5. Price is in column G, which is the fourth column of D2:H7, not the seventh column of the worksheet.
=VLOOKUP("SKU-104",D2:H7,4,FALSE)
That formula returns 45, the price of the Laptop Stand.
Count from the range’s first column, not from column A
VLOOKUP numbers columns from the left edge of its second argument:
| Worksheet column | Header | VLOOKUP index |
|---|---|---|
| D | SKU | 1 |
| E | Product | 2 |
| F | Category | 3 |
| G | Price | 4 |
| H | Stock | 5 |
If the field you want is already inside the range, change the index. For Price in this table, that index is 4.
If the range itself is too narrow, widening it is the right repair. This formula fails because D2:F7 has only three columns (SKU, Product, and Category):
=VLOOKUP("SKU-104",D2:F7,4,FALSE)
It returns #REF! with the same out-of-bounds message. Restoring Price inside the range fixes it:
=VLOOKUP("SKU-104",D2:G7,4,FALSE)
That returns 45. =VLOOKUP("SKU-104",D2:F7,6,FALSE) fails the same way. The working index for Category in D2:F7 is 3, and that formula returns Office. Do not widen a range just to keep an index that was counted from the wrong starting column.
Index values below 1 are a different error. =VLOOKUP("SKU-104",D2:H7,0,FALSE) and the same formula with -1 both returned #VALUE!, with the message “Function VLOOKUP parameter 3 value is 0. It should be greater than or equal to 1.” (or -1 in place of 0). That is not the out-of-bounds #REF!.
When a working VLOOKUP suddenly goes out of bounds
The usual cause is that someone shortened the lookup range and left the index alone. This formula returns 45:
=VLOOKUP("SKU-104",D2:H7,4,FALSE)
After the range is cut to D2:F7, it becomes:
=VLOOKUP("SKU-104",D2:F7,4,FALSE)
The fourth column no longer exists, and the result is the same #REF!. Selecting only the SKU column does the same thing: =VLOOKUP("SKU-104",D2:D7,4,FALSE) also returns that out-of-bounds #REF!.
Deleting a worksheet column is not the same as editing the range by hand. I deleted the Category column (worksheet column F) from a working copy of =VLOOKUP("SKU-104",D2:H7,4,FALSE). Google Sheets rewrote the range to D2:G7 and left the 4 unchanged. The formula still calculated, but it returned 63 (Stock) instead of 45 (Price), with no error. A second formula that used index 5 for Stock became =VLOOKUP("SKU-104",D2:G7,5,FALSE) and then returned #REF! with the out-of-bounds message. Check the range and the index together after a column is deleted. A missing error is not proof the lookup still returns the right field.
The other common way this starts is a copied index. A colleague used 7 on a wider table, you pasted the formula and replaced only the range with D2:H7, and the 7 stayed put. In a report with one VLOOKUP per field, that can leave Product and Category working while Price shows #REF!.
An index array can fail on only one result
Google Sheets can return several columns from one VLOOKUP when you pass an array of indexes inside ARRAYFORMULA. This formula returns Laptop Stand, Office, and 45 across three cells:
=ARRAYFORMULA(VLOOKUP("SKU-104",D2:H7,{2,3,4},FALSE))
This one requests a column that is not there:
=ARRAYFORMULA(VLOOKUP("SKU-104",D2:H7,{2,3,6},FALSE))
The first two results are still Laptop Stand and Office. The third cell is #REF! with the same out-of-bounds message. Check every number in the array against COLUMNS(range), not just the first one.
ARRAYFORMULA is required for this pattern. Without it, =VLOOKUP("SKU-104",D2:H7,{2,3,4},FALSE) returned only Laptop Stand and did not spill. The same formula with {2,3,6} also returned only Laptop Stand and did not show #REF!, because only the first index was used.
FILTER and QUERY can hand VLOOKUP a narrower table
Sometimes the second argument is not a fixed rectangle. It is a table built by another formula, and you have to count the columns in that result, not in the original worksheet range.
This lookup filters the first three product columns and then asks for a fourth:
=VLOOKUP("SKU-104",FILTER(D2:F7,D2:D7<>""),4,FALSE)
COLUMNS(FILTER(D2:F7,D2:D7<>"")) returns 3, and the VLOOKUP returns #REF! with the out-of-bounds message. Including Price in the filter fixes it:
=VLOOKUP("SKU-104",FILTER(D2:G7,D2:D7<>""),4,FALSE)
That returns 45.
QUERY has the same constraint. This formula selects SKU, Product, and Price from the sample table, then asks for a fourth column:
=VLOOKUP("SKU-104",QUERY(D1:H7,"select D, E, G",1),4,FALSE)
The QUERY result is three columns wide, so the VLOOKUP returns #REF! with the out-of-bounds message. Price is the third column of that result, regardless of its worksheet position:
=VLOOKUP("SKU-104",QUERY(D1:H7,"select D, E, G",1),3,FALSE)
That returns 45. select Col1, Col2, Col4 produced the same three-column table and the same VLOOKUP results. select SKU, Product, Price did not; it returned #VALUE! with “Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: SKU.”
When the range comes from FILTER, QUERY, or IMPORTRANGE, evaluate that inner formula on its own first and count the columns it actually returns. I did not run IMPORTRANGE in this test; the limit is still the width of the table VLOOKUP receives.
Use MATCH on the header instead of typing the index
If the table has headers, you do not have to hard-code the return-column number. This is the approach I would use on an existing VLOOKUP report:
=VLOOKUP("SKU-104",D2:H7,MATCH("Price",D1:H1,0),FALSE)
It returns 45, because MATCH("Price",D1:H1,0) returns 4. If someone later reorders the columns inside the same-width table, the formula can still find Price by its header.
The header range must cover the same columns, in the same order, as the VLOOKUP range. If it does not, MATCH can hand VLOOKUP an index that is out of bounds. MATCH("Price",D1:H1,0) is 4, and =VLOOKUP("SKU-104",D2:E7,MATCH("Price",D1:H1,0),FALSE) returned the same out-of-bounds #REF!, because D2:E7 has only two columns.
A missing header is a different error. MATCH("Cost",D1:H1,0) returned #N/A, with the message “Did not find value ‘Cost’ in MATCH evaluation.” Wrapping that MATCH in VLOOKUP produced the same #N/A, not the out-of-bounds #REF!.
Duplicate headers also matter. I added a second Price header in column H of a copy of the header row, with 99 in the corresponding SKU-104 cell. MATCH("Price",D40:H40,0) returned 4, and the VLOOKUP that used it returned 45, the first Price, not 99.
XLOOKUP and INDEX/MATCH skip the column index
For a new Google Sheets lookup, I prefer XLOOKUP when the lookup and return columns are straightforward:
=XLOOKUP("SKU-104",D2:D7,G2:G7,"Not found")
It returns 45. The formula names the SKU column and the Price column separately, so there is no index to run past the edge of a table. The "Not found" argument is only for a missing SKU; it does not hide a broken column index, because XLOOKUP does not use one.
INDEX and MATCH do the same job:
=INDEX(G2:G7,MATCH("SKU-104",D2:D7,0))
That also returns 45. MATCH finds the row for SKU-104, and INDEX returns the Price on that row. For a comparison of these methods, see XLOOKUP vs INDEX MATCH vs VLOOKUP.
HLOOKUP has the same limit on rows
VLOOKUP counts columns. HLOOKUP counts rows, and the #REF! message is “HLOOKUP evaluates to an out of bounds range.”
To test it without overwriting the product list, enter this transposed SKU-104 record in A20:B24:
| Cell | A | B |
|---|---|---|
| Row 20 | Field | SKU-104 |
| Row 21 | Product | Laptop Stand |
| Row 22 | Category | Office |
| Row 23 | Price | 45 |
| Row 24 | Stock | 63 |
=HLOOKUP("SKU-104",A20:B24,6,FALSE) returns #REF! with that HLOOKUP out-of-bounds message, because the range has five rows (ROWS(A20:B24) returns 5). =HLOOKUP("SKU-104",A20:B24,4,FALSE) returns 45. The row index is counted from the first row of the selected range. If the range starts at row 20, that first row still has index 1.
IFERROR will hide the #REF! without fixing it
This wrapper does not repair the lookup:
=IFERROR(VLOOKUP("SKU-104",D2:H7,7,FALSE),"")
It returns a blank cell instead of #REF!. In a price report, that blank can look like missing product data. Fix the range or the index first so the formula returns 45:
=VLOOKUP("SKU-104",D2:H7,4,FALSE)
Use IFERROR only when you have a deliberate value for a missing lookup key. A missing SKU is a different error: =VLOOKUP("SKU-999",D2:H7,4,FALSE) returned #N/A, with the message “Did not find value ‘SKU-999’ in VLOOKUP evaluation.”
If the formula returns a value but it is the wrong field, see VLOOKUP Returns the Wrong Value. For other causes of #REF!, see How to Fix a #REF! Error in Excel. If several lookup errors are showing up at once, the Lookup Errors Troubleshooting Guide covers the broader diagnosis.