Excel 中包含多个表格的公式

Formula with Multiple Tables in Excel

这是我第一个 post 堆栈溢出。多年来我通过阅读别人的问题得到了你的很多帮助,但我终于找到了一个我找不到答案的问题。

这似乎是一个相对简单的问题,但我如何在不以任何方式修改两个表格的情况下从屏幕截图中显示的电子表格中找到 Fruit(单元格 B15)的平均成本?

不幸的是,我不能 post 图片(因为没有声誉)所以我会在这里描述它:

两个表:

Table 1 (A1:B5): 
Column A = Products (Apple, Celery, Lemon, Carrot);
Column B = Type (Fruit, Vegetable, Fruit, Vegetable

Table 2 (A7:B11):
Column A = Products (Apple, Celery, Lemon, Carrot);
Column B = Cost ([=11=].45, [=11=].60, [=11=].72, [=11=].86)

B14: "Fruit" <--What I want to find the average price of;

B15: Where the formula will go

谢谢。

在单元格 B15 中输入此公式:

=SUM(IF((B2:B5="fruit"),INDEX(B8:B11,N(IF(1,MATCH(A2:A5,A8:A11,))))))/SUM(IF(B2:B5="fruit",1))

This is an array formula and must be confirmed with Ctrl+Shift+Enter.

还要考虑 =SUMIF(range, criteria, [sum_range]) 函数。它可能会在一个简单的语句中完成您所需要的。