Marsh,
I'm using the following code to round one number by another increment. I
can't get it to return the correct results when it's passed a 'whole'
(relative to the increment) number.
For example:
Rnd2Num(1.4,.05,vb_rounddown) = 1.35
In this case, because 1.4 is divisible by 0.05 I want it to return 1.4. The
line:
If CInt(Temp) = Temp Then
is supposed to catch this case.
Function Rnd2Num(Amt As Variant, RoundAmt As Variant, Direction As Integer)
As Double
On Error Resume Next
Dim Temp As Double
Temp = Amt / RoundAmt
If CInt(Temp) = Temp Then
Rnd2Num = Amt
Else
If Direction = vb_rounddown Then
Temp = Int(Temp)
Else
Temp = Int(Temp) + 1
End If
Rnd2Num = Temp * RoundAmt
End If
'Debug.Print Rnd2Num
End Function
I tried adding a small amount.
Any suggestions?
TIA,
Josh