Lookup headers and use COUNTA to sum the data under it

六眼飞鱼酱① 提交于 2019-12-23 01:33:39

问题


I am trying to find a specific column based on month (B1) and count the number of cells with x under it based on by the designated region (D1).

This is what I figured it would be but it is coming back as #VALUE!.

=SUMPRODUCT(SUBTOTAL(3,INDEX($1:$1048576,0,MATCH($B$1,$3:$3,‌​0))),--(($A:$A=D$1))‌​)

回答1:


SUBTOTAL does not work with INDEX, use OFFSET:

=SUMPRODUCT(SUBTOTAL(3,OFFSET(A3,ROW(1:9),MATCH($B$1,3:3,0)-1))*(A4:A12=D1))


Edit

This version is dynamic:

=SUMPRODUCT(SUBTOTAL(3,OFFSET(A3,ROW(INDIRECT("1:" & MATCH("zzz",A:A)-3)),MATCH($B$1,3:3,0)-1))*(A4:INDEX(A:A,MATCH("zzz",A:A))=D1))

It will automatically resize based on how much data is in Column A. It is set that the title row is in row 3, if that changes then you need to change the 3:3 and the -3 to the row number where the titles are located.



来源:https://stackoverflow.com/questions/45334641/lookup-headers-and-use-counta-to-sum-the-data-under-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!