SOLVED

Excel formulas

Brass Contributor

What I'm trying to do:

Cell A1 has a numeric value. In cell B1, I want to be able to do the following:

If A1 is =<12, enter the value in cell A1 into cell B1

If A1 is greater than 12, enter 12 into cell B1

My formula is:

=IF((OR(E9<=12, E9>12)), E9,12)

What is wrong with my logic?

 

4 Replies

Hi @marty007 

 

Please try below formula:

 

=IF(A1<=12,A1,12)

 

Thanks

Tauqeer

best response confirmed by marty007 (Brass Contributor)
Solution

@marty007 

Re: ``If A1 is =<12, enter the value in cell A1 into cell B1. If A1 is greater than 12, enter 12 into cell B1``

 

=MIN(12, A1)

 

-----

 

Re: ``=IF((OR(E9<=12, E9>12)), E9,12). What is wrong with my logic?``

 

E9 is always "<=12" (less than or equal to) or ">12" (greater than).  So the condition is always TRUE, and E9 is always returned.

 

I suspect you intended to write IF(OR(E9=12,E9<12), E9, 12)

 

But that is the same as IF(E9<=12, E9, 12), which is better -- but not better than the MIN expression above.

Your formula worked, thanks. Someone else sent me this formula: =MIN(12, A1). I don't understand it as well as yours but it seems simpler.
IF(E9<=12, E9, 12) seems easier for me to grasp but =MIN(12, A1) is clearly simpler. I'm learning!
Thanks very much.
1 best response

Accepted Solutions
best response confirmed by marty007 (Brass Contributor)
Solution

@marty007 

Re: ``If A1 is =<12, enter the value in cell A1 into cell B1. If A1 is greater than 12, enter 12 into cell B1``

 

=MIN(12, A1)

 

-----

 

Re: ``=IF((OR(E9<=12, E9>12)), E9,12). What is wrong with my logic?``

 

E9 is always "<=12" (less than or equal to) or ">12" (greater than).  So the condition is always TRUE, and E9 is always returned.

 

I suspect you intended to write IF(OR(E9=12,E9<12), E9, 12)

 

But that is the same as IF(E9<=12, E9, 12), which is better -- but not better than the MIN expression above.

View solution in original post