简体   繁体   English

Excel公式IF(AND #VALUE!错误

[英]Excel Formula IF(AND #VALUE! Error

I am working on a financial model in excel. 我正在使用Excel建立财务模型。 If the number of customers is between 1-10000, the cost is .20 per customer per month, 10000-100000 is .15 per customer per month, 100k and 1MIL is .10 per customer per month and > 1MIL is .08 per month per customer. 如果客户数量在1-10000之间,则成本为每位客户每月0.20,10000-100000为每位客户每月0.15,100k和1MIL为每位客户每月0.10,大于1MIL则为每月0.08。每个客户。

What I would like to do is create a formula where if the cell that references the number of customers at that month is within those values above, the cost per month changes depending on the number of cstomers. 我想做的是创建一个公式,如果引用该月客户数量的单元格在上述值之内,则每月成本将根据客户数量而变化。

This is what I have: 这就是我所拥有的:

=IF(AND(B6>=1,B6<=10000),$Q$6), IF(AND(B6>10000,B6<=100000),$Q$7), IF(AND(B6>100000,B6<=1000000),$Q$8),IF(AND(B6>1000000),$Q$9)

Q6, Q7, Q8, Q9 are respectively: $.20, $.15, $.10, $.08 Q6,Q7,Q8和Q9分别是:$。20,$。15,$。10,$。08

My B6 cell is the cell that is pulling over the number of customers from another sheet. 我的B6单元格是从另一张纸上吸引大量客户的单元格。

I am getting a #VALUE! 我得到一个#VALUE! Error when I use this formula. 使用此公式时出错。 It works if I simply have: =IF(AND(B6>=1,B6<=10000),$Q$6) which leads me to believe that my logic is wrong with all of the IF statements, and I should be using ELSEIF but I am not sure the syntax for that. 如果我简单地拥有:= IF(AND(B6> = 1,B6 <= 10000),$ Q $ 6),它将使我相信所有IF语句的逻辑都是错误的,因此我应该使用ELSEIF但我不确定其语法。

Help is appreciated! 感谢帮助!

So this is how I fixed this issue in case anyone had the same issue: 因此,如果有人遇到相同的问题,这就是我解决的方法:

=IF(B6<=10000,$Q$6,IF(B6<=100000,$Q$7,IF(B6<1000000,$Q$7)))

By nesting the if statements with higher values excel automatically recognizes the max value for that if statement! 通过嵌套具有较高值的​​if语句,excel会自动识别该if语句的最大值!

It seems that you are closing the IF statements too soon. 您似乎太早关闭了IF语句。 Your formula repaired would look like, 修复后的配方看起来像

=IF(AND(B6>=1,B6<=10000),$Q$6, IF(AND(B6>10000,B6<=100000), $Q$7, IF(AND(B6>100000,B6<=1000000), $Q$8, IF(AND(B6>1000000),$Q$9))))

If you start at the upper limit, you can reduce the conditions with sequential logic. 如果从上限开始,则可以使用顺序逻辑来减少条件。

=IF(B6>1000000,$Q$9, IF(B6>100000, $Q$8, IF(B6>10000, $Q$7, IF(B6>=1,$Q$6, 0))))

You could probably do that a little more easily like this 您可以像这样更容易地做到这一点

=IF(B6>1000000,$Q$9,IF(B6>100000,$Q$8,IF(B6>10000,$Q$7,IF(B6>=1,$Q$6,"Error))) ) =IF(B6>1000000,$Q$9,IF(B6>100000,$Q$8,IF(B6>10000,$Q$7,IF(B6>=1,$Q$6,"Error))) ))

You don't need AND because the IF functions are implicitly checking a range because the previous IFs rule out ranges of values 您不需要AND因为IF函数会隐式检查范围,因为以前的IF排除了值的范围

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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