×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• 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.

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

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

(OP)
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.

Gary

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

2
MROUND(number,multiple)

Number   is the value to round.

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

Remarks
Box,
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.

Examples

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?
gearguru

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

(OP)
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.

Gary

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

Gary,

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.

#### Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a partâ€™s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!