如何根据Excel中的多个If计算总和?

时间:2015-08-21 21:38:51

标签: excel function if-statement sum

背景是我正在制作预算电子表格。我在不同的日子有不同的账单。 (即周一到期的账单和10日到期的账单)

我想要一个能够在D栏中输入/输出适当金额的功能,以及在E栏中输入/输出资金的原因说明。

目前我创建了两个不同的公式(可能不正确)。

E列的公式:(已经在文档中,除了我无法向单元格添加其他文本的事实外,似乎工作正常)

=IF(DAY(C36)=7," Amy Pay","")&IF(DAY(C36)=22," Amy Pay","")&IF(DAY(C36)=8," Family Bills","")&IF(DAY(C36)=6," Dollar Shave Club","")&IF(DAY(C36)=2," Amy Cap One VISA","")&IF(DAY(C36)=3," Chase VISA","")&IF(DAY(C36)=8," Being Smart","")&IF(DAY(C36)=17," Gym","")&IF(DAY(C36)=11," Netflix","")&IF(DAY(C36)=19," Cap One MC","")&IF(DAY(C36)=29," CenturyLink","")&IF(DAY(C36)=6," Haley Cap One Visa","")&IF(DAY(C36)=10," SRP","")&IF(DAY(C36)=23, "Car Payment","")&IF(DAY(C36)=30, "Rent","")&IF((B36)="Mon"," Monday","")&IF((B36)="Fri"," Friday","")&IF((B36)="Fri"," Haley Pay","")

D列的公式:(不在列中,因为它不按我想要的方式工作)

=IF(DAY(B40)=7,"1474.22","")&IF(DAY(B40)=22,"1474.22","")&IF(DAY(B40)=8,"-100","")&IF(DAY(B40)=6,"-9","")&IF(DAY(B40)=2,"-100","")&IF(DAY(B40)=3,"-100","")&IF(DAY(B40)=8,"-400","")&IF(DAY(B40)=17,"-20.05","")&IF(DAY(B40)=11,"-8.63","")&IF(DAY(B40)=19,"-450","")&IF(DAY(B40)=29,"-50","")&IF(DAY(B40)=6,"-150","")&IF(DAY(B40)=10,"-200","")&IF(DAY(B40)=23,"-325","")&IF(DAY(B40)=30,"-500","")&IF((A40)="Mon","-125","")&IF((A40)="Fri","-325","")&IF((A40)="Fri","400","")

http://imgur.com/IBINweh

enter image description here

问题在于,在D列中,它不是提供数字的总和,而是列出列中的数字。

http://imgur.com/rPDS5h2

enter image description here

我有一个建议要添加= SUM(在IF之前(函数,但是当我这样做时,#VALUE!是该字段的结果。使用此公式:(通过将附加文本更改为/ CVs0f1v来查看图像)

=SUM(IF(DAY(B40)=7,"1474.22","")&IF(DAY(B40)=22,"1474.22","")&IF(DAY(B40)=8,"-100","")&IF(DAY(B40)=6,"-9","")&IF(DAY(B40)=2,"-100","")&IF(DAY(B40)=3,"-100","")&IF(DAY(B40)=8,"-400","")&IF(DAY(B40)=17,"-20.05","")&IF(DAY(B40)=11,"-8.63","")&IF(DAY(B40)=19,"-450","")&IF(DAY(B40)=29,"-50","")&IF(DAY(B40)=6,"-150","")&IF(DAY(B40)=10,"-200","")&IF(DAY(B40)=23,"-325","")&IF(DAY(B40)=30,"-500","")&IF((A40)="Mon","-125","")&IF((A40)="Fri","-325","")&IF((A40)="Fri","400",""))

关于如何让所有人填充和总结的任何想法?

原谅我的非Excel大师知识 - 努力学习。 :D

-Amy

2 个答案:

答案 0 :(得分:2)

如果您从第一个工作公式中获取所有选项并更改检索它们的方法,您将拥有一个更通用的工作表,可以轻松接受新添加和计划修改。

Family Bill Payment Schedule

  1. 在右侧的几个未使用的列中,在日期中进行陷阱以及发生的操作。我正在使用Y&列Z.你在6日发生了两件事,所以我把它们放在一起。
  2. 在其他几个未使用的列中使用星期几和相关文本。我用了V&列W.星期日的默认值是1.
  3. 在E36中使用此公式,=TRIM(IFERROR(VLOOKUP(DAY(C36),$Y:$Z, 2, FALSE), "")&" "&IFERROR(VLOOKUP(WEEKDAY(C36),$V:$W, 2, FALSE), ""))

  4. 根据需要填写。
  5. 如果您想要B列中的星期几,请使用=C36并使用自定义数字格式ddddddd

    参考文献:

    VLOOKUP function {
    {3}}

答案 1 :(得分:0)

您正在连接看起来像数字的文本字符串。您可能想要添加实数:

=SUM(IF(DAY(B40)=7,1474.22,0) + IF(DAY(B40)=22,0) + ...
但是,每当我看到一个像你所拥有的那样复杂的公式时,我会考虑寻找一个不同的解决方案 - 想到Vlookup。

另外,使用VLOOKUP表,你会看到你有一些冲突 - 例如:你列出了B40 = 8的相同条件,以返回两个不同的值;和A40 = Fri的条件相同,也返回两个不同的值。