简体   繁体   中英

Excel Formula IF(AND #VALUE! Error

I am working on a financial model in 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.

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

My B6 cell is the cell that is pulling over the number of customers from another sheet.

I am getting a #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.

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!

It seems that you are closing the IF statements too soon. 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))) )

You don't need AND because the IF functions are implicitly checking a range because the previous IFs rule out ranges of values

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