Rounding up to a factor

Sep 28

I found this function today ( its been around since 99) , its rounds up or down to your specified rounding amount.

For example round 2.64 upwards to the nearest .1 would = 2.7

Or 12.34 upward to the nearest 5 would = 15

Function Rnd2Num(Amt As Variant, RoundAmt As Variant, Direction As Integer) As Double
'From: Arvin Meyer Newsgroups: <a href="" target="_blank"></a> -Access
'Date: 1999/04/21

On Error Resume Next
Dim Temp As Double, rnddown
rnddown = 0
Temp = Amt / RoundAmt
If Int(Temp) = Temp Then
    Rnd2Num = Amt
    If Direction = rnddown Then
       Temp = Int(Temp)
       Temp = Int(Temp) + 1
    End If
    Rnd2Num = Temp * RoundAmt
End If
End Function
Function testround()
    MsgBox Rnd2Num(2.64, 0.1, 1)
End Function

If you need some help on a project drop leave a comment on the post and I will reply.