G
Guest
I am wrapping this expression with the RoundtoNearest function.
I want it to round to the nearest 1 up
example: 34.23 = 35 , 36.55 = 37
=RoundToNearest(((Nz(Sum([LBS]),0)+nz(Sum([CF])*50,0))/2000),1,up)
but it it not working why?
I am using the following code
Optional varUp As Variant) As Double
Dim dblTemp As Double
Dim lngTemp As Long
dblTemp = dblNumber / varRoundAmount
lngTemp = CLng(dblTemp)
If lngTemp = dblTemp Then
RoundToNearest = dblNumber
Else
If IsMissing(varUp) Then
' round down
dblTemp = lngTemp
Else
' round up
dblTemp = lngTemp + 1
End If
RoundToNearest = dblTemp * varRoundAmount
End If
End Function
Thanks
I want it to round to the nearest 1 up
example: 34.23 = 35 , 36.55 = 37
=RoundToNearest(((Nz(Sum([LBS]),0)+nz(Sum([CF])*50,0))/2000),1,up)
but it it not working why?
I am using the following code
Optional varUp As Variant) As Double
Dim dblTemp As Double
Dim lngTemp As Long
dblTemp = dblNumber / varRoundAmount
lngTemp = CLng(dblTemp)
If lngTemp = dblTemp Then
RoundToNearest = dblNumber
Else
If IsMissing(varUp) Then
' round down
dblTemp = lngTemp
Else
' round up
dblTemp = lngTemp + 1
End If
RoundToNearest = dblTemp * varRoundAmount
End If
End Function
Thanks