Advanced Rounding

amir9s

New Member
Joined
Jun 10, 2016
Messages
9
Hello everyone,
I'm having a difficult time figuring this problem out.
I'm trying to round up and down numbers depending on their decimal value.

Basically
  • if decimal is equal/over .65, then round up to the next whole number
  • if decimal is between 0.25 and .65 then enter 0.5
  • and finally if decimal is smaller than 0.25 then round it down to the previous whole number.

as an example:
1.24 returns 1.0
1.25 returns 1.5
3.8 returns 4.0
2.65 returns 3.0
2.64 returns 2.5
and so on...

Thank you in advance
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
It's a bit messy, but a nested IF statement could work for this. Assuming the value is in A1 and the rounded value is in B1:

=IF(A1-INT(A1)<0.25,ROUNDDOWN(A1,0),IF(AND(A1-INT(A1)>=0.25,A1-INT(A1)<0.65),INT(A1)+0.5,ROUNDUP(A1,0)))
 
Upvote 0
B1 is irrelevant for the above example, but I meant to say that I had typed the above equation into cell B1 to verify that it would work.
 
Upvote 0
to split hairs, how about
Code:
=IF(AND(MOD(A1,1)>=0.25,MOD(A1,1)<0.65),MROUND(A1,0.5),ROUND(A1,0))
 
Upvote 0
Or

=INT(A1)+LOOKUP(MOD(A1,1),{0,25,65}%,{0,0.5,1})
 
Upvote 0
shg, I actually considered that version, but it generates an inaccurate result when the decimal is exactly .65. I got it to work by using:

=INT(A1)+LOOKUP(MOD(A1,1),{0,0.25,0.6499},{0,0.5,1})

but I didn't know how many 9's would be required, so I stuck with the original version.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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