Excel Supreme

Excel track · Exercise 46 of 86 Paid

INDEX MATCH: look left of the key

Return a value from the left of the key with INDEX and MATCH.

Intermediate

Four priced products

Read-only data · answer in B7

In B7, return the product name in A2:A5 for the SKU in B6 with INDEX and MATCH.

AB
1ProductUnit price
2Cable reel8.5
3Junction box3.25
4Conduit2.75
5Trunking5.4
6Which price?3.25
7Product

Download this grid (.xlsx) Two tabs: the grid you see, and the answer.

B7

What it does

Here the answer sits to the left of the value being searched. B6 holds the price 3.25, which is the second entry in B2:B5, so MATCH returns 2. INDEX then reads the second cell of A2:A5, and B7 shows Junction box.

VLOOKUP cannot make that move. Its column count starts at the key and runs forward, so no argument reaches a column sitting before the key. Choosing the two ranges separately is what lets the lookup run left.

The zero matters even more on this sheet. The price column runs 8.5, 3.25, 2.75, 5.4, which is not sorted in either direction. Approximate search stops somewhere in that order and can read a neighbouring row. With 0, a price that is not in the list gives #N/A.

Syntax

=INDEX(range, MATCH(value, list, 0))

Worked example

On Four priced products, =INDEX(A2:A5,MATCH(B6,B2:B5,0)) returns Junction box.

=INDEX(A2:A5,MATCH(B6,B2:B5,0))

Common errors

Error codes for INDEX with MATCH
ErrorWhat it means and how to fix it
#N/AMATCH found no exact 3.25 in B2:B5, so INDEX was handed a position that does not exist.
#REF!INDEX was pointed at a range shorter than the position MATCH returned, so the row number runs past A5.
Wrong productThe zero was left off, so MATCH accepted a price it never found and INDEX read a neighbouring product.

At work

A price list where you know what something cost and need the part name, which sits to the left of the price.