简体   繁体   English

Excel公式-Countifs +间接+跨多行匹配

[英]Excel Formula - Countifs + Indirect + Match across multiple rows

I am trying to count records that are located in different rows which: 我正在尝试计算位于不同行中的记录:

  • are within a certain date range eg. 在某个日期范围内,例如 starting from >= 01/01/2017 从> = 01/01/2017开始
  • are within the same month as defined above eg. 在上述定义的同一个月内,例如 < 31/01/2017 <31/01/2017
  • have records within a range across multiple rows, row numbers must be obtained via MATCH by finding the row of the cell that contains "Negative Comment 1" and MATCH the row number of the cell that contains "Negative Comment 5" (eg. "Negative 1" is in Row 220, "Negative 5" is in row 224, hence the rance would be I220:AZZ224 which spans 5 rows) 在多行范围内有记录,必须通过MATCH通过找到包含“否定注释1”的单元格的行来获取行号,并MATCH包含“否定注释5”的单元格的行号(例如,“否定的”) 1”位于第220行,“ Negative 5”位于第224行,因此范围为I220:AZZ224(跨越5行)

Formula looks like this: 公式如下所示:

=IFERROR(COUNTIFS(
// starting date
'MED-FB-YTD'!$I$18:$AZZ$18,">="&DATE(YEAR(E3),MONTH(E3),"1")-1,

// end date
'MED-FB-YTD'!$I$18:$AZZ$18,"<"&DATE(YEAR(E3),MONTH(E3),"31"),

// define range between Negative Comment 1 to 5 and count all records that are not empty
INDIRECT("'MED-FB-YTD'!$I$"&MATCH("Negative Comment 1",'MED-FB-YTD'!$C:$C,0)&":$AZZ$"&MATCH("Negative Comment 5",'MED-FB-YTD'!$C:$C,0)),"<>"),

"ERR")

The problem is here 问题在这里

// define range between Negative Comment 1 to 5 and count all records that are not empty
INDIRECT("'MED-FB-YTD'!$I$"&MATCH("Negative Comment 1",'MED-FB-YTD'!$C:$C,0)&":$AZZ$"&MATCH("Negative Comment 5",'MED-FB-YTD'!$C:$C,0)),"<>"),

The formula works fine if I change the range to count from 5 rows to 1 row (eg. change from I220:AZZ224 to I220:AZZ220 ), which leads me to believe that the countifs() formula doesnt like to count cells across multiple rows, which in turn however is unlikely as I used countifs() before and did just that. 如果我将范围从5行更改为1行(例如,从I220:AZZ224更改为I220:AZZ220 ),则该公式可以正常工作,这使我相信countifs()公式不喜欢对多行中的单元格进行计数,但是这不太可能,因为我之前使用过countifs()并做到了这一点。

Right now, I am always getting the #value error. 现在,我总是遇到#value错误。 Any suggestions? 有什么建议么?

EDIT 编辑

Sample data below: 以下示例数据:

MED-FB-YTD (data source): MED-FB-YTD(数据源):

数据

Display form: 显示形式:

形成

There seems to be something missing in the formula which you have pasted at the end (I mean in your problematic line). 您最后粘贴的公式中似乎缺少某些内容(我的意思是您的问题行)。

Can you re-share your formula? 您可以重新分享您的公式吗?

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

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