Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Round to ANY value equation,, ie..25-50-100-13 anything

Round to ANY value equation,, ie..25-50-100-13 anything

Round to ANY value equation,, ie..25-50-100-13 anything

This may help someone.  I recently developed a spreadsheet that calculated some pressure settings for a machine I was in charge of.  The pressure gage read in 50 psi incriments, but my spreadsheet output was rounded to the nearest 1 psi.  Excel will round to decimal places, not numbers, ie..1-10-100-etc..., or 0.1-0.01-0.001 etc.  So I developed an equation that will round to the nearest set value, being any number, interger or otherwise.  You could round to the nearest Pi if you wanted to.  So here it is:

# = the number you want to round
RN = the number to round to
IP = take the interger part

   Rounded Number = IP[(#/RN)+.5] * RN

Basically, take your number #, and divide it by what you want to round to, RN.  Add .5 to it, and take the integer part.  Then multiply by the RN number again.

Good luck to all, hope this helps someone.


RE: Round to ANY value equation,, ie..25-50-100-13 anything


Number   is the value to round.

Multiple   is the multiple to which you want to round number.

doesn't Excel "MROUND()" function do the same?
Here is how Excel Help explains it:
MROUND rounds up, away from zero, if the remainder of dividing number by multiple is greater than or equal to half the value of multiple.


MROUND(10, 3) equals 9

MROUND(-10, -3) equals -9

MROUND(1.3, 0.2) equals 1.4

MROUND(5, -2) equals #NUM!
Or I did not catch something?

RE: Round to ANY value equation,, ie..25-50-100-13 anything

That is a great function.  I never knew it existed.  I've been using Excel for about 6 years, and never had any training.  So when I couldn't find a function to do what I wanted, I had to make up my own.  

Thanks for pointing this out.  But....  My equation could be used anywhere.  Fortran doesn't have a rounding function, or it didn't when I used to use it.  And I'm sure several of the newer languages can't do that.  So maybe someone can use it that way.

But thanks for the update on Excel.  Just shows my own ignorance.


RE: Round to ANY value equation,, ie..25-50-100-13 anything


An application like Excel has so much functionality it's almost impossible to know everything about it.  That's what is great about these forums (try this experiment: ask your question here and also ask the 'Office Assistant' then compare results ).  

Btw, I recall using a variation on your function in a GW-BASIC program years ago!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close