代码改变世界

Excel Index Match 用法

2013-01-12 20:56  小sa  阅读(998)  评论(0编辑  收藏  举报

INDEX / MATCH -- Example 4

Instead of matching information in column headings, you may need to match information that's stored in the columns, as shown in the table below.

 
A
B
C
D
1
Code
Item
Size
Price
2
SW001
Sweater
Small
10
3
JK001
Jacket
Small
30
4
PN001
Pants
Small
25
5
SW002
Sweater
Med
12
6
JK002
Jacket
Med
35
7
PN002
Pants
Med
30
8
SW003
Sweater
Large
14
9
JK003
Jacket
Large
40
10
PN003
Pants
Large
35
11        
12 Item Size Price Code
13 Jacket Med
?
?

In this INDEX / MATCH example, instead of columns headings of Small, Med, and Large, the size is stored in column C.

You need to find the price from column D, when Jacket is in column B, and Med is in column C.

  1. Set up the worksheet as shown at right
  2. Enter the following formula in cell C13:      
    =INDEX($D$2:$D$10,MATCH(1,(A13=$B$2:$B$10)*(B13=$C$2:$C$10),0))
  3. This is an array formula, so hold Ctrl + Shift, and press the Enter key to see the result.

Curly brackets will be automatically added to the formula (don't type them yourself!), so the final result will look like this:

{=INDEX($D$2:$D$10,MATCH(1,(A13=$B$2:$B$10)*(B13=$C$2:$C$10),0))}

Next, create a similar INDEX/MATCH formula in cell D13, to get the correct code from column A.