multiple if statements

vickiecroft

New Member
Joined
Nov 21, 2005
Messages
34
In Column B I have a number with multiple digits. The first part of my formula I want to round up to the next whole number, then if the number is greater than or equal to 18 place the number 18 in the cell, if the number is less than or equal 6 place the number 6 in the cell, but if the number in the cell is 7 through 17 I want it to place the actual number in the cell.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi,

When you say:
but if the number in the cell is 7 through 17 I want it to place the actual number in the cell

Do you mean Un-Rounded?


Book1
BC
15.56786
211.245711.2457
325.7896518
Sheet292
Cell Formulas
RangeFormula
C1=IF(ROUNDUP(B1,0)>=18,18,IF(ROUNDUP(B1,0)<=6,6,B1))
 
Upvote 0
Perhaps something like this:

=MIN(18,MAX(ROUND(B2,0),6)) <-Except, I realize now this does not take into account the exact value if it falls within the range and will return the rounded value regardless.

Or

=IF(ROUND(B2,0)>=18,18,IF(ROUND(B2,0)<=6,6,B2))
 
Last edited:
Upvote 0
@ OP and dried,

We can also use the MEDIAN function:


Book1
BCD
15.567866
211.245711.245711.2457
325.789651818
Sheet292
Cell Formulas
RangeFormula
C1=IF(ROUNDUP(B1,0)>=18,18,IF(ROUNDUP(B1,0)<=6,6,B1))
D1=MEDIAN(18,B1,6)
 
Upvote 0
Almost. My MIN/MAX would have worked if I could keep it simple and still return the exact value. Point in case, 17.5+ will return 18 with MIN/MAX, but 17.5+ with MEDIAN.

MEDIAN works great for the decimal values from 6.5-17.4 though. MIN/MAX will return the rounded results. :( At this time, I would like to petition Microsoft for a new function.. to be able to calculate on a rounded number but return original number if necessary. Let's call it ROUNDX() heh.
 
Last edited:
Upvote 0
Then the MEDIAN can work this way:


Book1
BCD
15.567866
211.245711.245711.2457
325.789651818
417.71818
Sheet292
Cell Formulas
RangeFormula
C1=IF(ROUNDUP(B1,0)>=18,18,IF(ROUNDUP(B1,0)<=6,6,B1))
D1=MEDIAN(18,IF(ROUNDUP(B1,0)>=18,18,B1),6)
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top