Rounded up

bhelmy

Registered User.
Local time
Today, 18:04
Joined
Dec 6, 2015
Messages
62
Hi
Need Code to make Rounded up

EX

no Code to Be
1.1 2
1.4 2
1.6 2
1.99 2
1 1
 
Also

Code:
Public Function Ceiling(ByVal X As Double, Optional ByVal Factor As Double = 1) As Double
    ' X is the value you want to round
    ' is the multiple to which you want to round
    Ceiling = (Int(X / Factor) - (X / Factor - Int(X / Factor) > 0)) * Factor
End Function

from

http://www.tek-tips.com/faqs.cfm?fid=5031

seems to do what you want.
 
i already encountered same post before:

Code:
Public Function RoundUp(ByVal d As Double) As Double

    Dim ret As Double
    ret = Int(d)
    
    If d > ret Then ret = ret + 1
    RoundUp = ret
End Function
 
I personnaly like
Code:
Public Function RoundUp(ByVal lNumber As Double) As Double
    RoundUp = -Int(-(lNumber))
End Function

An other way :
Code:
Public Function RoundUp(ByVal lNumber As Double) As Double
If (lNumber - Int(lNumber)) = 0 Then 
  RoundUp = lNumber
Else 
    RoundUp = Round(lNumber+ 0.5) 
End If 
End Function

There are many ways to do this :)
 

Users who are viewing this thread

Back
Top Bottom