Skip to content

How to vLOOKUP with two criteria in Excel

Look up a value that depends on two columns, such as product and size, with XLOOKUP and a joined key, INDEX and MATCH, or SUMIFS.

A price list has a row for every product in every size. The product name alone does not identify a price, and neither does the size. You need both together.

VLOOKUP looks at one column. The classic workaround is a helper column that joins the two keys, then a lookup on that. In current Excel you do not need the helper: XLOOKUP accepts an array, so you can build the combined key inside the formula.

=XLOOKUP(F2&G2, A2:A9&B2:B9, C2:C9) joins the wanted product and size, joins the product and size columns row by row, and finds the position where the two match. It returns the price from the same position in column C.

A joined key can produce false matches when the pieces blur together. "AB" and "C" gives the same text as "A" and "BC". If your keys can do that, join them with a separator that never appears in the data, such as a pipe.

If the value you are returning is a number and each pair is unique, SUMIFS is an easy alternative: it sums the matching row, which is the price itself. It returns 0 rather than an error when nothing matches, so use it with care.

Older workbooks use INDEX and MATCH with a multiplied test: MATCH(1,(A2:A9=F2)*(B2:B9=G2),0). It does the same thing and works in every version. See the Lookups track for the full set of patterns.

3 ways to do it

1XLOOKUP with a joined key

=XLOOKUP(F2&G2,A2:A9&B2:B9,C2:C9)

  1. Put the product in F2 and the size in G2.
  2. In H2 type =XLOOKUP(F2&G2,A2:A9&B2:B9,C2:C9).
  3. Add a fourth argument such as "No price" to control what shows when the pair is missing.

2INDEX and MATCH with two tests

=INDEX(C2:C9,MATCH(1,(A2:A9=F2)*(B2:B9=G2),0))

  1. MATCH finds the row where both tests are true: the product test multiplied by the size test equals 1.
  2. INDEX returns the price from that row of column C.

3SUMIFS for a unique numeric result

=SUMIFS(C2:C9,A2:A9,F2,B2:B9,G2)

  1. Use the price column as the sum range and test product and size in two criteria pairs.
  2. Check each pair appears only once, or the prices will add up.

Try it yourself

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In H2, return the price for the product in F2 in the size in G2.

Answer in H2.

H2
A
B
C
D
E
F
G
H
1
Product
Size
Price
Product
Size
Price
2
Widget
S
4.20
Gadget
M
3
Widget
M
5.10
Bracket
M
4
Widget
L
6.30
5
Gadget
S
7.00
6
Gadget
M
8.40
7
Gadget
L
9.90
8
Bracket
S
2.10
9
Bracket
L
3.60

Learn it properly, one graded sheet at a time.

Logic and text covers this in lesson 14, TEXTSPLIT.