简体   繁体   English

我可以使用 SUMPRODUCT 忽略空白单元格吗?

[英]Can i use SUMPRODUCT to ignore blank cells?

My spreadsheet has a list of names (some are repeated) in column A, a list of numbers stored in a string in column B, and column C uses a formula to get the first number of the string in column B. In column E have created a list of the unique names from column A, in column F a number of times they appear in the data list and in column G i then want to fetch the corresponding number data from column C each time it appears in the list to calculate average numbers.我的电子表格在 A 列中有一个名称列表(有些是重复的),在 B 列中有一个存储在字符串中的数字列表,并且 C 列使用公式获取 B 列中字符串的第一个数字。在 E 列中有从 A 列创建了一个唯一名称列表,在 F 列中它们出现在数据列表中的次数,然后在 G 列中,我希望每次出现在列表中时都从 C 列中获取相应的数字数据以计算平均值数字。

I have tried this我试过这个

=SUMPRODUCT(($A$1:INDEX($A:$A,COUNTA($A:$A))=$E4)*($C$2:INDEX($C:$C,COUNTA($C:$C))))/$F4

The problem i have is that in the list of data some of the cells in column C are blank so i am getting a #VALUE error.我遇到的问题是,在数据列表中,C 列中的一些单元格是空白的,所以我收到#VALUE错误。

Here is a screenshot of what i am trying:这是我正在尝试的屏幕截图:

新输出

Is there anyway to tell SUMPRODUCT to skip the rows where there is no number data?有没有办法告诉SUMPRODUCT跳过没有数字数据的行?

Obviously this is just an example and my actual spreadsheet is a little more complicated, there are thousands of rows of data and the names are repeated many times over.显然这只是一个例子,我的实际电子表格要复杂一些,有数千行数据,并且名称重复了很多次。

Empty cells are not your problem.空单元格不是您的问题。 It would just be accepted in a formula like yours.它只会在像你这样的公式中被接受。 Unfortunately the problem is because you have gaps, COUNTA will return a range that's not equal to column A > COUNTA in column A will return 15, whereas COUNTA in column C will return 11. Unequal ranges will return #VALUE不幸的是,问题是因为您有间隙, COUNTA将返回一个不等于 A 列的范围 > A 列中的COUNTA将返回 15,而 C 列中的COUNTA将返回 11。不相等的范围将返回#VALUE

In this specific case your issue is resolved through:在这种特定情况下,您的问题通过以下方式解决:

=SUMPRODUCT(($A$1:INDEX($A:$A,COUNTA($A:$A))=$E4)*($C$1:INDEX($C:$C,COUNTA($A:$A))))/$F4

在此处输入图像描述

In G4, copied down:在 G4 中,向下复制:

=SUMIF($A:$A,$E4,$C:$C)/$F4

Edit: SUMIF() can use whole column reference of which bounded on used range only, and can avoid to use dynamic range.编辑: SUMIF() 可以使用仅限于使用范围的整列引用,并且可以避免使用动态范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM