weAscend.com

Public Function vCeiling(dblNum As Double, _

dblSig As Double) As Variant

Dim intPlaces As Integer
Dim dblX As Double

If Not (Sgn(dblNum) = Sgn(dblSig)) Then GoTo Error_Handler

If (dblSig = Int(dblSig)) Then
    intPlaces = 0
Else
    intPlaces = Len(Str(dblSig)) - (InStr(1, Str(dblSig), "."))
End If

dblX = (dblNum * 10 ^ intPlaces) / (dblSig * 10 ^ intPlaces)
If dblX = Int(dblX) Then GoTo Leave_Alone

vCeiling = ((Int(dblX) + 1) * (dblSig * 10 ^ intPlaces)) * 1 / 10 ^
intPlaces

Exit_Function:
    Exit Function

Leave_Alone:
    vCeiling = dblNum
    GoTo Exit_Function

Error_Handler:
    vCeiling = "Error"
    GoTo Exit_Function

End Function

 

Contact Us