- Home
·
- Math/Dates
·
- Round a number to the nearest anything you want. like if you wanted to round the number 53 to the n
Round a number to the nearest anything you want. like if you wanted to round the number 53 to the n
Round a number to the nearest anything you want. like if you wanted to round the number 53 to the nearest 5, it would round it up to 55.
Rate Round a number to the nearest anything you want. like if you wanted to round the number 53 to the n
(1(1 Vote))
'mynumber = 48
'mynumber = sround(mynumber, 45)
'now, after calling this mynumber will = 45.
Function sRound(number As Long, onum As Integer) As Long
Dim p As Long, r As Long, z As Long
p = number / onum
If InStr(1, CStr(p), ".") Then
r = Right(CStr(p), Len(CStr(p)) - InStr(1, CStr(p), "."))
p = Left(CStr(p), InStr(1, CStr(p), ".") - 1)
z = Round(CLng("." & r))
If z = 0 Then
sRound = (p * onum)
Else
sRound = ((p + 1) * onum)
End If
End If
If p = 0 Then p = 1
sRound = (p * onum)
End Function
Round a number to the nearest anything you want. like if you wanted to round the number 53 to the n Comments
No comments yet — be the first to post one!
Post a Comment