Roundup

H

Harvey

Can anyone help with this problem. I have a report with
one section adding up the total cost of materials, which
is fine, and say the answer is £35.79. My question is,
how do I round it up to the next £5.00 to get an answer
of £40.00.

Thank's Harvey
 
R

Randy Harris

Can anyone help with this problem. I have a report with
one section adding up the total cost of materials, which
is fine, and say the answer is £35.79. My question is,
how do I round it up to the next £5.00 to get an answer
of £40.00.

Thank's Harvey

One possible solution:
IIf(A / 5 = A \ 5, A, (A \ 5 + 1) * 5)

HTH,
Randy
 
D

Dan

Good Day!

Here is another way to round a number by building your own
function and then calling it to return the answer.

Public Function RoundANumber(InputNumber As Double,
NearestWhat As Double)

RoundANumber = Int(InputNumber / NearestWhat + 0.5) *
NearestWhat

End Function

In your example you would call it as:

RoundANumber(35.79,10)

And it would return 40.

RoundANumber(35.79,0.1) would return 35.8

Good Luck!
 
H

Harvey

Thank you Dan. Works fine apart from one thing. For some
reason, anything just over 20 revert's to 20 instead of
25. All the other examples I tried work's fine.

Thank again Harvey
 

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

Top