Sta raditi kad se trazi zaokruzivanje na najblizi 0.25? Sta raditi kad se zahteva zaokruzivanje na zapocetih 15 minuta? Sta raditi kad se priznaje samo zavrsenih 15 minuta, nepotpunih 15 minuta na kraju se ne priznaje? Evo funkcija koja pomaze:
Function RoundUpDown(varNumber As Variant, varDelta As Variant) As Variant
'*******************************************
'Name: RoundDelta (Function)
'Purpose: round varNumber to varDelta, up or down
'Inputs: varNumber = number to round
' varDelta = rounding precission
' +varDelta = rounds UP
' -varDelta = rounds DOWN
'Example: RoundUpDown(5.12,+0.25) = 5.25
' RoundUpDown(5.12,-0.25) = 5.00
'Output: varNumber rounded UP/DOWN
'*******************************************
Dim varTemp As Variant
'VarDelta must be <>0
If varDelta = 0 Then varDelta = 1
varTemp = CDec(varNumber / varDelta)
If Int(varTemp) = varTemp Then
RoundUpDown = varNumber
Else
RoundUpDown = Int(((varNumber + varDelta) + varDelta) / varDelta - 1) * varDelta
End If
End Function