简体   繁体   中英

Excel - Write a sum formula with a condition in a cell

In this example I want to write a formula in the end of Col3 (C11), to calculate the total like this :

if the cell value in Col1 is less than the value in Col3, then take Col1 else take Col3 to calculate the total of Col3.

So, in my example, the total of Col3 is : 1960.95 + 2764.37 + 12500 + 5787.34 + 2582.09 + 12500 + 12500 + 499.98 = 51094.73

I wrote a code to get the sum. But is it possible to write a formula in C11?

Here is my example :
         A           B      C           D
         Col1        Col2   Col3        Col4
         1 960,95    0,00   12 500,00   0,00
         2 764,37    0,00   12 500,00   0,00
         20 584,38   0,00   12 500,00   8 084,38
         5 787,34    0,00   12 500,00   0,00
         2 582,09    0,00   12 500,00   0,00
         44 605,50   0,00   12 500,00   32 105,50
         44 602,50   0,00   12 500,00   32 102,50
         499,98      0,00   12 500,00   0,00

Total    123 387,11  0,00   51 094,73   72 292,38

Use this array formula:

=SUM(IF(A2:A9<C2:C9,A2:A9,C2:C9))

Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting Edit mode. If done correctly then Excel will put {} around the formula.

在此处输入图片说明

你可以只创建COL5与式=IF(A2<C2,A2,C2)上的每一行然后SUM COL5总数。

How about:

=SUMIF(A3:A10,"<12500",A3:A10)+SUMIF(A3:B10,">12500",C3:C10)

not included anything for equal too though..:) but just change > to >=

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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