Try making a custom sub like this:
Sub rInt(iNumber,iDecs)
'Check if the number is a Whole Number or a Decimal
If FormatNumber(iNumber,iDecs) >
FormatNumber(iNumber,0) AND FormatNumber(iNumber,iDecs) <
(FormatNumber(iNumber,0)+1) Then
rInt = FormatNumber(iNumber,iDecs)
Else
rInt = Fix(iNumber)
End If
End Sub
|
Then all you have to do is call it by using it like: rInt(1.22,2)
There for rInt(2.00000,2) and rInt(2.000011,2) would give out 2
But rInt(2.0109,2) would give out 2.01 because 2 decimal places back is
a nonZero number. Respectively, rInt(2.000312,4) would give 2.0003.