Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-01-2016, 05:16 AM
paulkaye paulkaye is offline Custom rounding up Windows 7 64bit Custom rounding up Office 2007
Advanced Beginner
Custom rounding up
 
Join Date: Nov 2011
Posts: 84
paulkaye is on a distinguished road
Default Custom rounding up

I regularly need to perform this manual rounding operation, and would love to find an automated solution:

If the decimal of the number is between .0 and .4, it's rounded up to the next integer. If the decimal of the number is between .5 and .9, it's rounded up to one integer larger than the next integer.

Examples:

1.3 → 2
4.5 → 6
8.9 → 10


11 → 12

A formula would be fine - I could just paste the formula in the adjacent column. Alternatively, I'd be happy to highlight the relevant cells and run a macro on them.

Thanks in advance!
Reply With Quote
  #2  
Old 09-01-2016, 07:41 AM
xor xor is offline Custom rounding up Windows 10 Custom rounding up Office 2016
Expert
 
Join Date: Oct 2015
Posts: 1,097
xor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to all
Default

=if(mod(a1,1)<=0.4,int(a1)+1,if((mod(a1,1)>0.4)*(m od(a1,1)<=0.9),int(a1)+2,""))
Reply With Quote
  #3  
Old 09-01-2016, 08:10 AM
paulkaye paulkaye is offline Custom rounding up Windows 7 64bit Custom rounding up Office 2007
Advanced Beginner
Custom rounding up
 
Join Date: Nov 2011
Posts: 84
paulkaye is on a distinguished road
Default

Thank you.
I edited the formula to keep zero as zero:
=IF(A1=0,0,IF(MOD(A1,1)<=0.4,INT(A1)+1,IF((MOD(A1, 1)>0.4)*(m od(A1,1)<=0.9),INT(A1)+2,"")))
I've "stored" it in cell B1. Unfortunately I'm getting strange results when I copy-paste it into other cells. Some work, and some do not! I copied the formula into cells to the right of the cells containing the original values. Here is the result:

6.7 #NAME?
6.6 #NAME?
4.1 5
5.2 6
0 0
0 0
9 10
6.9 #NAME?
10.7 #NAME?
6.7 #NAME?
9.4 10
4.2 5
0 0
0 0
7 8
0 0
2.5 #NAME?
14.5 #NAME?
1.7 #NAME?
0 0
7.8 #NAME?
8.2 9
6.6 #NAME?
0 0
0 0
0 0
0 0
9.7 #NAME?
3.2 4
4.6 #NAME?
9.8 #NAME?


Any ideas?!

Last edited by paulkaye; 09-01-2016 at 08:12 AM. Reason: pasted values came out distorted
Reply With Quote
  #4  
Old 09-01-2016, 08:47 AM
xor xor is offline Custom rounding up Windows 10 Custom rounding up Office 2016
Expert
 
Join Date: Oct 2015
Posts: 1,097
xor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to all
Default

It seems to work if I have understood you correct.
Attached Files
File Type: xlsx RoundingProblem.xlsx (9.0 KB, 6 views)
Reply With Quote
  #5  
Old 09-01-2016, 08:48 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Custom rounding up Windows 7 64bit Custom rounding up Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,766
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

=IF(A1=0,0,IF(MOD(A1,1)<=0.4,INT(A1)+1,IF((MOD(A1, 1)>0.4)*(mod(A1,1)<=0.9),INT(A1)+2,"")))

There seems to have been a typo in the mod function you pasted ( m od instead of mod), or the forum gremlins at work :-)
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post

Last edited by Pecoflyer; 09-01-2016 at 09:21 AM. Reason: Corrected after a post by NoSpark
Reply With Quote
  #6  
Old 09-01-2016, 09:02 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Custom rounding up Windows 7 64bit Custom rounding up Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,766
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Just for the fun =CEILING(A1,1)+OR(MOD(A1,1)>0.4,MOD(A1,1)=0)

(tested with OOffice)
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #7  
Old 09-01-2016, 09:17 AM
NoSparks NoSparks is offline Custom rounding up Windows 7 64bit Custom rounding up Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 831
NoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really niceNoSparks is just really nice
Default

@ Peco

Don't be too hasty to call that a typo.

This forum doesn't always display what's typed or pasted into the reply box.
Wouldn't let me eliminate the space it added to a formula no matter how I tried.
https://www.msofficeforums.com/excel...tml#post103248
Reply With Quote
  #8  
Old 09-01-2016, 09:26 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Custom rounding up Windows 7 64bit Custom rounding up Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,766
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Now that you mention it, I seem to remember that editing problem.Strange. I will amend my post accordingly)

Thanks
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #9  
Old 09-03-2016, 11:12 PM
paulkaye paulkaye is offline Custom rounding up Windows 7 64bit Custom rounding up Office 2007
Advanced Beginner
Custom rounding up
 
Join Date: Nov 2011
Posts: 84
paulkaye is on a distinguished road
Default

That space in the original formula was the problem. Works perfectly now. Thanks, Xor, and everyone else!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom rounding up Excel Seems to be Rounding Twice Rather Than Once melissapete24 Excel 5 08-27-2016 12:51 AM
Custom rounding up Time Calc with rounding. billreed7 Excel 5 07-03-2016 06:43 PM
Rounding to nearest 0.25 Guloluseus Excel 5 10-27-2015 11:28 PM
Rounding values inconsistent required_username Excel 10 06-05-2014 05:35 AM
Custom formatting code - rounding problem venkys4u Excel 1 08-14-2012 07:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:08 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft