Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default How do I apply a rounding rule


Hi, I need to apply the rounding rule below for conducting our business when
dealing with a number that has a 0.5 ending:

Example:
If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

Please help! Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,766
Default How do I apply a rounding rule

Hi,

Not clear about your question. Why should 5.5 be 54 and 55.5 be 56. If
55.5 is 56, then 54.5 should be 55?

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"riffmastr7" wrote in message
...

Hi, I need to apply the rounding rule below for conducting our business
when
dealing with a number that has a 0.5 ending:

Example:
If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

Please help! Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default How do I apply a rounding rule

Hi, Ashish. Please read my example very carefully. I need excel to round 54.5
to 54. This is called ASTM rounding rules. It only becomes tricky when there
is a 0.5 in the end. Basically, when there is a .5 in the end, the number is
rounded to the nearest EVEN WHOLE number. Here it is again:

Example:

If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

"Ashish Mathur" wrote:

Hi,

Not clear about your question. Why should 5.5 be 54 and 55.5 be 56. If
55.5 is 56, then 54.5 should be 55?

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"riffmastr7" wrote in message
...

Hi, I need to apply the rounding rule below for conducting our business
when
dealing with a number that has a 0.5 ending:

Example:
If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

Please help! Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,766
Default How do I apply a rounding rule

Hi,

Sorry I did not get your question right. Please try this formula

IF(ISEVEN(INT(G7)),INT(G7),INT(G7)+1)

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"riffmastr7" wrote in message
...
Hi, Ashish. Please read my example very carefully. I need excel to round
54.5
to 54. This is called ASTM rounding rules. It only becomes tricky when
there
is a 0.5 in the end. Basically, when there is a .5 in the end, the number
is
rounded to the nearest EVEN WHOLE number. Here it is again:

Example:

If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

"Ashish Mathur" wrote:

Hi,

Not clear about your question. Why should 5.5 be 54 and 55.5 be 56. If
55.5 is 56, then 54.5 should be 55?

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"riffmastr7" wrote in message
...

Hi, I need to apply the rounding rule below for conducting our business
when
dealing with a number that has a 0.5 ending:

Example:
If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

Please help! Thanks.


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,651
Default How do I apply a rounding rule

Again reluctant to argue with an MVP, Ashish, but for the second time this
morning I'm not convinced by your answer. Have you had a long week? :-)

If there isn't a .5 at the end, you should round to the nearest whole
number. It is only when there is a .5 that you should look at odd or even.
You are rounding 54.9 to 54 when it should be 54, and you are rounding 55.1
to 56 when it should be 55.

Try =IF(OR(MOD(A2,1)<0.5,ISODD(A2)),ROUND(A2,0),ROUND DOWN(A2,0))
--
David Biddulph

Ashish Mathur wrote:
Hi,

Sorry I did not get your question right. Please try this formula

IF(ISEVEN(INT(G7)),INT(G7),INT(G7)+1)


"riffmastr7" wrote in message
...
Hi, Ashish. Please read my example very carefully. I need excel to
round 54.5
to 54. This is called ASTM rounding rules. It only becomes tricky
when there
is a 0.5 in the end. Basically, when there is a .5 in the end, the
number is
rounded to the nearest EVEN WHOLE number. Here it is again:

Example:

If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

"Ashish Mathur" wrote:

Hi,

Not clear about your question. Why should 5.5 be 54 and 55.5 be
56. If 55.5 is 56, then 54.5 should be 55?

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"riffmastr7" wrote in message
...

Hi, I need to apply the rounding rule below for conducting our
business when
dealing with a number that has a 0.5 ending:

Example:
If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

Please help! Thanks.





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,766
Default How do I apply a rounding rule

Hi,

As can be judged from my first response, I was not clear about what was
required and I still do not know what is ASTM. I really appreciate you
telling me that my answer is incorrect. From your second para, I understand
that the rounding rule has to be applied only when there is a .5. I could
not infer/read that in the original post. I though that all decimal numbers
had to be rounded off to the the closest even number.

Also, I have not tried your solution - may be it actually is the solution to
the question.

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"David Biddulph" <groups [at] biddulph.org.uk wrote in message
...
Again reluctant to argue with an MVP, Ashish, but for the second time this
morning I'm not convinced by your answer. Have you had a long week? :-)

If there isn't a .5 at the end, you should round to the nearest whole
number. It is only when there is a .5 that you should look at odd or
even.
You are rounding 54.9 to 54 when it should be 54, and you are rounding
55.1 to 56 when it should be 55.

Try =IF(OR(MOD(A2,1)<0.5,ISODD(A2)),ROUND(A2,0),ROUND DOWN(A2,0))
--
David Biddulph

Ashish Mathur wrote:
Hi,

Sorry I did not get your question right. Please try this formula

IF(ISEVEN(INT(G7)),INT(G7),INT(G7)+1)


"riffmastr7" wrote in message
...
Hi, Ashish. Please read my example very carefully. I need excel to
round 54.5
to 54. This is called ASTM rounding rules. It only becomes tricky
when there
is a 0.5 in the end. Basically, when there is a .5 in the end, the
number is
rounded to the nearest EVEN WHOLE number. Here it is again:

Example:

If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

"Ashish Mathur" wrote:

Hi,

Not clear about your question. Why should 5.5 be 54 and 55.5 be
56. If 55.5 is 56, then 54.5 should be 55?

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"riffmastr7" wrote in message
...

Hi, I need to apply the rounding rule below for conducting our
business when
dealing with a number that has a 0.5 ending:

Example:
If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

Please help! Thanks.



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default How do I apply a rounding rule

Hi, David. Very good! This works! I want to take it one step further and make
it a calculation formula. I want to make the average of 4 numbers to follow
the same rounding rule.

Example: 57, 52, 52, 49

The average of the numbers above is 52.5. I want to put it in a single
formula to average them and come out as 52.

Please help.

"David Biddulph" wrote:

Again reluctant to argue with an MVP, Ashish, but for the second time this
morning I'm not convinced by your answer. Have you had a long week? :-)

If there isn't a .5 at the end, you should round to the nearest whole
number. It is only when there is a .5 that you should look at odd or even.
You are rounding 54.9 to 54 when it should be 54, and you are rounding 55.1
to 56 when it should be 55.

Try =IF(OR(MOD(A2,1)<0.5,ISODD(A2)),ROUND(A2,0),ROUND DOWN(A2,0))
--
David Biddulph

Ashish Mathur wrote:
Hi,

Sorry I did not get your question right. Please try this formula

IF(ISEVEN(INT(G7)),INT(G7),INT(G7)+1)


"riffmastr7" wrote in message
...
Hi, Ashish. Please read my example very carefully. I need excel to
round 54.5
to 54. This is called ASTM rounding rules. It only becomes tricky
when there
is a 0.5 in the end. Basically, when there is a .5 in the end, the
number is
rounded to the nearest EVEN WHOLE number. Here it is again:

Example:

If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

"Ashish Mathur" wrote:

Hi,

Not clear about your question. Why should 5.5 be 54 and 55.5 be
56. If 55.5 is 56, then 54.5 should be 55?

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"riffmastr7" wrote in message
...

Hi, I need to apply the rounding rule below for conducting our
business when
dealing with a number that has a 0.5 ending:

Example:
If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

Please help! Thanks.




  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default How do I apply a rounding rule

On Fri, 20 Feb 2009 13:50:01 -0800, riffmastr7
wrote:


Hi, I need to apply the rounding rule below for conducting our business when
dealing with a number that has a 0.5 ending:

Example:
If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

Please help! Thanks.


It can be done easily with a UDF since VBA uses the so-called Banker's rounding
algorithm.

To enter the UDF, <alt-F11 opens the VB Editor. Ensure your project is
highlighted in the Project Explorer window, then Insert/Module and paste the
code below into the window that opens.

To use it, enter a formula like =RndToEven(num, Digits)

==========================
Function RndToEven(num As Double, Digits As Long) As Double
RndToEven = Round(num, Digits)
End Function
========================
--ron
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 837
Default How do I apply a rounding rule

VBA's Round function is not as capable (unless improved in 2007) as the
worksheet ROUND function. In particular:
- VBA Round does not support Digits<0
- VBA Round is not well buffered against binary differences that have no
impact on the 15 decimal digit display, and so will sometimes produce
unintended results.

The VBA code I posted several years ago
http://groups.google.com/group/micro...7fce6145b70d69
addresses both of these issues.

Jerry

"Ron Rosenfeld" wrote:

On Fri, 20 Feb 2009 13:50:01 -0800, riffmastr7
wrote:


Hi, I need to apply the rounding rule below for conducting our business when
dealing with a number that has a 0.5 ending:

Example:
If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

Please help! Thanks.


It can be done easily with a UDF since VBA uses the so-called Banker's rounding
algorithm.

To enter the UDF, <alt-F11 opens the VB Editor. Ensure your project is
highlighted in the Project Explorer window, then Insert/Module and paste the
code below into the window that opens.

To use it, enter a formula like =RndToEven(num, Digits)

==========================
Function RndToEven(num As Double, Digits As Long) As Double
RndToEven = Round(num, Digits)
End Function
========================
--ron

  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default How do I apply a rounding rule

On Fri, 20 Feb 2009 21:00:01 -0800, Jerry W. Lewis
wrote:

VBA's Round function is not as capable (unless improved in 2007) as the
worksheet ROUND function. In particular:
- VBA Round does not support Digits<0
- VBA Round is not well buffered against binary differences that have no
impact on the 15 decimal digit display, and so will sometimes produce
unintended results.

The VBA code I posted several years ago
http://groups.google.com/group/micro...7fce6145b70d69
addresses both of these issues.

Jerry


Thanks for posting that. And for the sake of the thread, here is Jerry's code:

==============================
Function ASTMround(number As Double, _
Optional num_digits As Integer = 0) As Double
' round exactly 5 to even per ASTM standard
' requires Excel 2000 or later
Dim x
If num_digits <= 0 Then
' VBA round does not accept num_digits < 0
ASTMround = Round(number / 10 ^ -num_digits) * 10 ^ -num_digits
Else
' buffer against binary approximations by rounding to an integer
' CDbl(CStr()) ensures that we get the primary binary _
representation the decimal display
ASTMround = Round(CDbl(CStr(number * 10 ^ num_digits))) _
/ 10 ^ num_digits
End If
End Function
=================================
--ron


  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default How do I apply a rounding rule

Hi, Jerry. I appreciate the help. How do I use this in the spreadsheet. I put
it in VBA. How do I apply/ use this function? Please let me know. Also I want
to have a calculation (AVE) and this rounding rule all in one formula. Please
let me know how to do this.

Example: 57, 52, 52, 49

The average of these numbers is 52.5. I need excel to calculate the average
of these numbers and follow the ASTM rounding rule to give a result of 52
right away.

"Jerry W. Lewis" wrote:

VBA's Round function is not as capable (unless improved in 2007) as the
worksheet ROUND function. In particular:
- VBA Round does not support Digits<0
- VBA Round is not well buffered against binary differences that have no
impact on the 15 decimal digit display, and so will sometimes produce
unintended results.

The VBA code I posted several years ago
http://groups.google.com/group/micro...7fce6145b70d69
addresses both of these issues.

Jerry

"Ron Rosenfeld" wrote:

On Fri, 20 Feb 2009 13:50:01 -0800, riffmastr7
wrote:


Hi, I need to apply the rounding rule below for conducting our business when
dealing with a number that has a 0.5 ending:

Example:
If the average is 54.5, I need excel to round it to 54.
If the average is 55.5, I need excel to round it to 56.

Please help! Thanks.


It can be done easily with a UDF since VBA uses the so-called Banker's rounding
algorithm.

To enter the UDF, <alt-F11 opens the VB Editor. Ensure your project is
highlighted in the Project Explorer window, then Insert/Module and paste the
code below into the window that opens.

To use it, enter a formula like =RndToEven(num, Digits)

==========================
Function RndToEven(num As Double, Digits As Long) As Double
RndToEven = Round(num, Digits)
End Function
========================
--ron

  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default How do I apply a rounding rule

On Sat, 21 Feb 2009 11:27:01 -0800, riffmastr7
wrote:

Hi, Jerry. I appreciate the help. How do I use this in the spreadsheet. I put
it in VBA. How do I apply/ use this function? Please let me know. Also I want
to have a calculation (AVE) and this rounding rule all in one formula. Please
let me know how to do this.

Example: 57, 52, 52, 49

The average of these numbers is 52.5. I need excel to calculate the average
of these numbers and follow the ASTM rounding rule to give a result of 52
right away.


If your values are in A1:A4, then:

=ASTMround(AVERAGE(A1:A4))

--ron
  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default How do I apply a rounding rule

You are awesome, Ron!!!!! Thanks very much!! You are a life-saver!!! I really
appreciate it!

riffmastr7

"Ron Rosenfeld" wrote:

On Sat, 21 Feb 2009 11:27:01 -0800, riffmastr7
wrote:

Hi, Jerry. I appreciate the help. How do I use this in the spreadsheet. I put
it in VBA. How do I apply/ use this function? Please let me know. Also I want
to have a calculation (AVE) and this rounding rule all in one formula. Please
let me know how to do this.

Example: 57, 52, 52, 49

The average of these numbers is 52.5. I need excel to calculate the average
of these numbers and follow the ASTM rounding rule to give a result of 52
right away.


If your values are in A1:A4, then:

=ASTMround(AVERAGE(A1:A4))

--ron

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If/Then Rule Honorbar Excel Discussion (Misc queries) 2 January 26th 09 05:17 PM
How many conditions can I apply to a cell? I need to apply 8. Markus Excel Discussion (Misc queries) 2 July 10th 08 01:06 PM
7 Function rule Helpme Excel Worksheet Functions 4 December 29th 06 01:41 AM
How to apply rounding across a range of cells with other formulae Steve T Excel Worksheet Functions 1 October 20th 05 07:39 PM
How do I set up a time sheet using the 7/8 rounding rule? Randy Excel Worksheet Functions 1 May 27th 05 03:30 AM


All times are GMT +1. The time now is 05:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"