Ravindra BagaleCourses & study guides

4. Lookup Functions

4.2 VLOOKUP Approximate Match and the Column-Index Trap

In short: Approximate match (TRUE) finds the largest value less than or equal to the lookup value.

Approximate match (TRUE) finds the largest value less than or equal to the lookup value. The first column must be sorted ascending. It is used for slabs and bands (4.9), never for IDs.

The column-index trap. col_index_num is a hard-coded number. If someone inserts a column in Stores (say Pincode after Area), column 5 is no longer City Manager – your formula silently returns the pincode.

Before insert After inserting "Pincode" as column E
=VLOOKUP(G2,Stores!$A$2:$F$8,5,FALSE) → Amir same formula → 440010 (wrong!)

Ways to avoid it:

  1. Use MATCH for the column number: =VLOOKUP(G2,Stores!$A$2:$G$8,MATCH("City Manager",Stores!$A$1:$G$1,0),FALSE)
  2. Use INDEX + MATCH (4.4) or XLOOKUP (4.6), which point to the return column directly.

Other VLOOKUP limits: it cannot look left (return a column before the lookup column), it returns only the first match, and a col_index larger than the table width gives #REF!.

Ravindra Bagale's Tip

Many students count the columns on their fingers to write col_index_num – and when a new column is added to the table, all the reports go wrong, without any error. Instead of counting the column index by hand, find the header with MATCH, or use XLOOKUP. If an interviewer asks about "the limitations of VLOOKUP", make this your first point.

Practice task

Write a VLOOKUP that returns City Manager, insert a Pincode column in Stores, and watch it break. Rewrite it with MATCH so that it survives the insert.