How to use discontinuous range in SUMIF

后端 未结 1 1150
一生所求
一生所求 2021-01-13 17:30

I\'m learning to use SUMIF in excel. Usually in the first argument in this formula is a continuous range (something like this A1:F1). But now I really need to choose somethi

相关标签:
1条回答
  • 2021-01-13 18:16

    Clever idea to use a discontinuous range (also known as a multi-area range).

    But it won't work.

    Yes, you can create a dicontinuous range using range syntax SUMIF((A1,C1,E1,G1),...) a named range (select the cells and then insert->range->define), the UNION() function, or INDIRECT(), but none of them will work, because SUMIF() doesn't support discontinuous ranges.

    So you have to cheat. Your question has been asked before, as I found by googling "sumif discontinuous":

    http://www.mrexcel.com/forum/excel-questions/226429-sumif-discontinuous-cells.html

    Adapting Oaktree's answer we get:

    =SUMPRODUCT(--(MOD(COLUMN($A1:$S1),2)=1),--($A1:$S1>V1),$B1:$T1)
    

    How does it work? It creates three lists, and finds the value of each element in each list, then multiplies them together. The first parameter is 1 for the odd columns and 0 for the even columns. The second parameter is 1 if it's greater than V1, otherwise 0. The third parameter is the values one column over.

    0 讨论(0)
提交回复
热议问题