Friday, January 13, 2006

banker's rounding

Public Function BRound(ByVal Dec As Variant, Optional ByVal prec As Integer = 0) As Currency

' Banker's Rounding

' sidenote by mike buen:
' a wrapper function for excel banker's rounding calling vb rounding
'
' VB Round function follows banker's rounding
' whereas if you will excel's built-in rounding, it uses arithmetic rounding

' this routine can be called inside excel, to use in excel, use: =BROUND(2.5,0), results in 2


BRound = VBA.Math.Round(Dec, prec)

End Function

0 Comments:

Post a Comment

<< Home