Answers for "round to integer vba"

VBA
2

vba round number

Function RoundTo(pNumber As Long, pFactor As Long)
    RoundTo = Round(pNumber / pFactor) * pFactor 
End Function
' ---------------------------------------------------------------
Sub TestMe()
    Debug.Print RoundTo(2543, 10)    			' => 2540
    Debug.Print RoundTo(2546, 10)    			' => 2550
    Debug.Print Application.RoundUp(10.1, 0) 	' => 10
    Debug.Print Application.RoundUp(10.6, 0) 	' => 11
    Debug.Print Application.RoundDown(10.6, 0) 	' => 10
End Sub
Posted by: Guest on January-31-2021
0

vba round to 2 decimals

Debug.Print Round(10.3456, 2)           ' 10.35 Double
Debug.Print Format(10.3456, "0.00")     ' 10.35 String (Variant)
Posted by: Guest on February-06-2021

Code answers related to "VBA"

Browse Popular Code Answers by Language