Forum Discussion
Need help with a formula
The formulas provided by HansVogelaar might be best for your purposes.
But the following might help you understand the syntax of IF expressions.
Your first formula was almost right. Write:
=IF(C35>=1200, 1200*E35, IF(C35<1200, C35*E35) )
or simply:
=IF(C35>=1200, 1200*E35, C35*E35)
If C35>=1200 is false, we know that C35<1200 is true. So IF(C35<1200... is superfluous.
-----
Your second formula and description are ambiguous. You wrote that if C35 is ``not within the range``, the formula should ``return a number zero``.
First, what range? You wrote C35<1200>=3600. We might interpret that to mean C35<1200 or C35>=3600 (!). But presumably you mean 1200<C35<=3600. That means 1200<C35 and C35<=3600.
However, we cannot write 1200<C35<=3600 in Excel. Instead, we might write:
=IF(AND(1200<C35, C35<=3600), C35-1200)*F35
or
=IF(AND(1200<C35, C35<=3600), (C35-1200)*F35, 0)
Technically, the last form is more efficient, albeit more "verbose" by a just few characters.
Second, do you really intend to return zero for C35>3600?! That is what you wrote (``not within the range``).
Or do you mean:
1. If C35<=1200, return zero
2. Else if C35<=3600, return (C36-1200)*F35
3. Else C35>3600, so return (3600-1200)*F35, not zero
That is what the formula provided by HansVogelaar implements.
Or we might write:
=IF(C35<=1200, 0, (MIN(3600, C35) - 1200)*F35)