W
willie
the following code should work just like the roundup() funciton in excell.
Except the in the step where the clng function is use. is rounding the
number and the result is not the same as in excell. example if the number is
100.1973 the result we get bacj is 100.21. can someone help me with this
Public Function Roundup(dblNumber As Double, varRoundAmount As Double, _
Optional varUp As Variant) As Double
Dim dblTemp As Double
Dim lngTemp As Long
dblTemp = dblNumber / varRoundAmount
lngTemp = CLng(dblTemp)
If lngTemp = dblTemp Then
Roundup = dblNumber
Else
If IsMissing(varUp) Then
' round down
dblTemp = lngTemp
Else
' round up
dblTemp = lngTemp + 1
End If
Roundup = dblTemp * varRoundAmount
End If
End Function
Except the in the step where the clng function is use. is rounding the
number and the result is not the same as in excell. example if the number is
100.1973 the result we get bacj is 100.21. can someone help me with this
Public Function Roundup(dblNumber As Double, varRoundAmount As Double, _
Optional varUp As Variant) As Double
Dim dblTemp As Double
Dim lngTemp As Long
dblTemp = dblNumber / varRoundAmount
lngTemp = CLng(dblTemp)
If lngTemp = dblTemp Then
Roundup = dblNumber
Else
If IsMissing(varUp) Then
' round down
dblTemp = lngTemp
Else
' round up
dblTemp = lngTemp + 1
End If
Roundup = dblTemp * varRoundAmount
End If
End Function