Using an idea posted by James Fortune recently the following will
round away from zero to any interval:
Public Function RoundFromZero(dblVal As Double, _
dblTo As Double) As Double
Dim intUpDown As Integer
If dblVal < 0 Then
intUpDown = 1
Else
intUpDown = -1
End If
RoundFromZero = intUpDown * (Int(dblVal / (intUpDown * dblTo)))
* dblTo
End Function
I would recommend against doing all the calculations in one go, as
that's where floating-point errors creep in. I would change this:
RoundFromZero = intUpDown * (Int(dblVal / (intUpDown * dblTo))) *
dblTo
....to this:
dblDenominator = intUpDown * dblTo
dblTestValue = dblVal / dblDenominator
RoundFromZero = intUpDown * IntUpDown * dblTo
....that approach is based on the principles outlined by Luke Chung
in his old article on writing your own rounding function, where he
recommended storing the result of any calculation in a variable of
known precision so that you don't compound floating-point
inaccuracies.