nearest multiple of

B

Barb

Hi Everyone
I need to return a value as a nearest multiple of 0.25. - similar to Ceiling
Function in Excel.Any ides how do I go about it?

thanks
Barb
 
B

Barb

Thank you both.
Works like a charm, but would you be so kind and explain it to me? I get
mulitplying and dividing - but why am I adding 0.25? I know I'm missing
something very simple.

thank you
Barb
 
S

Stefan Hoffmann

hi Barb,
Thank you both.
Works like a charm, but would you be so kind and explain it to me? I get
mulitplying and dividing - but why am I adding 0.25? I know I'm missing
something very simple.
You need to add .5 for rounding with Int() does:

Int() returns the integer part of a number, thus Int(number + .5)
returns a normal rounded value (next integer when larger then .5):

Int(2.3) = 2
Int(2.3 + .5) = Int(2.8) = 2

Int(2.6) = 2
Int(2.6 + .5) = Int(3.1) = 3

The .25 in Karls post should not work on all values:

Int(2.6 + .25) = Int(2.85) = 2

This value is independend from the multiple, it is always .5.


mfG
--> stefan <--
 

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