View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
James[_15_] James[_15_] is offline
external usenet poster
 
Posts: 1
Default VB Round( ) function

The problem is not with VBA, you need to read the number
in as a decimal number not an integer:

Function RoundFunc(Mark As Double) As Integer
RoundFunc = Round(Mark, 0)
End Function
-----Original Message-----
If in a cell on a spreadsheet, I enter the following

equation:
=ROUND(50.5, 0)
I obtain the result 51, which I would expect, since 0.5

should be rounded
up.

If I write the following VB funcion:

Function RoundFunc(Mark As Integer) As Integer
RoundFunc = Round(Mark, 0)
End Function

And then enter the following equation into a cell:
=RoundFunc(50.5)

I obtain the result 50. i.e. 0.5 is rounded down

Why the difference? Is there a function that I can use

in my VB code that
will round 0.5 up rather than down?


.