How do I make this formula support multiple rows/dragging?

走远了吗. 提交于 2020-01-05 08:54:16

问题


Continuation of this thread

Formula so far. Match[n] = match criteria, HEADER = header criteria etc. This formula Sums the values of the header cells that match a specific criteria, ie: 6502, with this formula, could match a header /6502, then take the value of RETURNSUM, a named range and add them with other matches.

    =SUMPRODUCT((RETURNSUM*
(MID(HEADER,2,4)=IF(LEN(Match5)=4,Match5&"",Match5&" ")))+(RETURNSUM*
(MID(HEADER,2,4)=IF(LEN(Match6)=4,Match6&"",Match6&" ")))+(RETURNSUM*
(MID(HEADER,2,4)=IF(LEN(Match7)=4,Match7&"",Match7&" ")))

The idea is that HEADER and RETURNSUM will become match criteria like the matches written above, that way it would be easier to punch new criterion into the search table. As of the moment, it doesn't support multiple rows/dragging even though it did when written as cell ranges like $A2:$F2.

The question I have is, how do I go about making the named cells multi-row capable?


回答1:


You can use =INDEX(array,row_num,[col_num]) to achieve this.

The index formula will only take results from the corresponding row. Row(1:1) will automatically update when dragged down so INDEX can then grab the next row.

=SUMPRODUCT((INDEX(RETURNSUM,ROW(1:1),0)* (MID(HEADER,2,4)=IF(LEN(Match5)=4,Match5&"",Match5&" ")))+(INDEX(RETURNSUM,ROW(1:1),0)* (MID(HEADER,2,4)=IF(LEN(Match6)=4,Match6&"",Match6&" ")))+(INDEX(RETURNSUM,ROW(1:1),0)* (MID(HEADER,2,4)=IF(LEN(Match7)=4,Match7&"",Match7&" "))))



来源:https://stackoverflow.com/questions/41743488/how-do-i-make-this-formula-support-multiple-rows-dragging

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