View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default rounding to nearest .5 in vba

On Wed, 3 Mar 2010 13:56:09 -0800, "Joe User" <joeu2004 wrote:

The VBA Round function rounds to the nearest even number.


That is not quite correct. For example, Round(2.xx,0) is 2 only when 2.xx
is exactly 2.50. Round(2.51,0) is 3.


I guess putting the formula example after defining the context for that
statement and before making that statement made it unclear that that statement
applied when the value fell exactly on the midpoint. I thought it was clear
that I was referring to midpoint issues, but I guess I'll have to be more
careful.


"And you did not define what you wanted to do in the event that your value fell
exactly on the midpoint.

"The general formula, would be Round(n/0.5,0)*0.5

"The VBA Round function rounds to the nearest even number."
--ron