August 19, 200520 yr Hi all, I have a need for a calculation that rounds up positive numbers to the nearest n, with n being equal to whatever value the user enters. I wrote a calc for it that seems to do precisely that but I just have this nagging feeling that it's "taking the long way around the barn". Can anyone simplify this? Case ( roundValue * Int( Round( inputNumber;0 ) / roundValue ) > inputNumber ; roundValue * Int( Round( inputNumber;0 ) / roundValue ); roundValue * Int( Round( inputNumber;0 ) / roundValue ) + roundValue) See the attachment for more info. Any help would be appreciated...thanks in advance! RoundTest.zip
August 19, 200520 yr To round up add 1/2 (0.5) to the number before rounding-> e.g. Round(123.456 ; 0) returns 123 Round(123.456 + 0.5; 0) returns 124 Mathematically, the standard is to round up for values >= x.5. So adding .5 forces any x.y to round up to x + 1.
August 19, 200520 yr Author I knew that the Ceiling() function had to be part of the solution, but I just couldn't come up with the correct formula. Thanks a bunch, Comment! B)
Create an account or sign in to comment