VLOOKUP Returns the Wrong Column After You Insert a Column
After a column insert, VLOOKUP can still look fine while a hard-coded column index returns Quantity instead of Amount. Point MATCH at the header, or use XLOOKUP.
本文目錄
The Amount for binder clips used to land in the result cell as 48.50. After someone slipped a Bin column into the catalog, the same VLOOKUP still shows a number, and there is no # error. The number is 12, which is the quantity.
This is not the missing-FALSE problem. The third argument, col_index_num, is a frozen count from the first column of the range, not a header name. Inserting a column can widen the range and still leave that 4 untouched. These results were measured in Google Sheets. I did not re-run the inserts in Excel.
The catalog, then a working lookup
Enter this in A1:D10. Type the amounts as ordinary numbers and format D2:D10 to two decimal places. Put the lookup SKU A-104 in F2.
| SKU | Name | Qty | Amount |
|---|---|---|---|
| A-104 | Binder clip | 12 | 48.50 |
| A-119 | Manila folder | 40 | 16.00 |
| B-203 | Stapler | 6 | 43.50 |
| B-210 | Tape dispenser | 8 | 27.20 |
| C-301 | Desk tray | 4 | 36.00 |
| C-308 | Letter opener | 15 | 9.75 |
| D-401 | Push pins | 100 | 6.40 |
| D-416 | Rubber bands | 50 | 4.25 |
| E-502 | Shipping labels | 20 | 18.90 |
=VLOOKUP(F2,A2:D10,4,FALSE)
Column 4 of A2:D10 is Amount, so A-104 returns 48.50.
If this formula already returns a neighbor’s amount for a SKU that is not in the list, that is the approximate-match default, not a column insert. See VLOOKUP 傳回錯誤值?近似匹配陷阱與其他 4 個原因.
A new column between Name and Qty
Select column C (Qty) and insert one column to the left. Put Bin in C1. You can leave the bin cells blank. Amount now sits in column E.
The formula I had in G2, =VLOOKUP(F2,A2:D10,4,FALSE), became:
=VLOOKUP(G2,A2:E10,4,FALSE)
The range widened from A2:D10 to A2:E10. The 4 stayed 4. The lookup cell also moved, from F2 to G2, because the new column was inserted to the left of it. G2 now shows 12 — Qty, which is the fourth column of the widened range — with no error.
That is the failure this page is about: a quiet wrong field, not #REF!.
Inserts that do not change the field
Start each of these from a fresh copy of the original four-column table and the original formula =VLOOKUP(F2,A2:D10,4,FALSE).
Insert a column at A, to the left of SKU. Every reference in that formula shifted one column right, to =VLOOKUP(G2,B2:E10,4,FALSE). The 4 still counted to Amount, and the result was still 48.50. Read the formula bar; the addresses you typed will not still be there.
Insert a column at E, immediately to the right of Amount. The range and the 4 were unchanged, and the result was still 48.50. The lookup cell itself moved again, because that new column sits to the left of F, so the formula became =VLOOKUP(G2,A2:D10,4,FALSE).
Only an insert inside the range, to the left of the return column, changes which field the 4 counts.
Deleting Amount is a different error
On a fresh copy of the original table, delete the Amount column. The formula became =VLOOKUP(E2,A2:C10,4,FALSE) and returned #REF!: “VLOOKUP evaluates to an out of bounds range.” The 4 is now wider than the three-column range that remains. That write-up is VLOOKUP out of bounds.
Point at the header, or drop the column number
Two repairs survive the mid-column insert. After Bin is in place (Amount in E):
=VLOOKUP(G2,A2:E10,MATCH("Amount",A1:E1,0),FALSE)
MATCH("Amount",A1:E1,0) returned 5. VLOOKUP then returned 48.50 again. If someone inserts another column later, the match moves with the header.
=XLOOKUP(G2,A2:A10,E2:E10)
That also returned 48.50. An XLOOKUP written before the insert, as =XLOOKUP(F2,A2:A10,D2:D10), rewrote to =XLOOKUP(G2,A2:A10,E2:E10) when Bin was inserted, and the result stayed 48.50. XLOOKUP has no column index.
=INDEX(E2:E10,MATCH(G2,A2:A10,0))
This returned 48.50 as well, and does not need a column number either. A side-by-side of the three functions is in XLOOKUP vs INDEX MATCH vs VLOOKUP.
Several SKUs at once
After the Bin column is in place, put A-104, B-203, and E-502 in G2:G4:
=ARRAYFORMULA(VLOOKUP(G2:G4,A2:E10,4,FALSE))
That spilled 12, 6, and 20 — still the fourth column, Qty. Switching the 4 to MATCH("Amount",A1:E1,0) spilled 48.50, 43.50, and 18.90. Leave empty cells under the formula so the spill has room; a blocked spill in this file returned #REF!, “Array result was not expanded because it would overwrite data in H11.”
A wrong value with no # sign also appears in the lookup overview, under the “wrong value, no error” row: Excel & Google Sheets Lookup Errors.
Sources
- Microsoft Support: VLOOKUP function (
col_index_num,#REF!when the index is wider than the range): https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1 - Google Docs Editors Help: VLOOKUP (column index is counted from the selected range): https://support.google.com/docs/answer/3093318
- Microsoft Support: XLOOKUP function (no column index): https://support.microsoft.com/en-us/office/xlookup-function-b7fd680e-6d10-43e6-84f9-88eae8bf5929
- Google Docs Editors Help: XLOOKUP: https://support.google.com/docs/answer/12405947