Rounding up decimal values

R

Richard

I need to know how to round any figure after a decimal point to even if its
less than 5...

e.g. 2.0433 to 2 decimal place = 2.04

but I want 2.0433 to 2 decimal place = 2.05 instead of 2.04
 
M

macropod

Hi Richard,

Try something based on the following function:

Function Roundup(MyVal As Single, Precision As Integer) As Single
Roundup = -(Int(MyVal * -10 ^ Precision) / 10 ^ Precision)
End Function

The Roundup Function takes two parameters - the value to be rounded and the # is the number of digits to which you want to round
(+ve and -ve values are accepted). And here's a sub to test with:

Sub Demo()
MsgBox Roundup(2.0433, 2)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Rounding up of decimal values 4
Formatring numbers to a variable set of decimal places 1
Currency and Rounding 0
Rounding Up question 2
Rounding 2 decimal Places 1
Rounding problem 9
Rounding number 15
Rounding Up 3

Top