rounding numbers to NEAREST odd integer?

A

Andrew Moeser

Is there a function to round numbers to the nearest odd
(or even) integer? The ODD function always rounds up,
whereas I want to round my data to the nearest odd
number. i.e. 1.5 rounding to 1 rather than 3

Thanks,
Andrew Moeser
 
H

Harlan Grove

Is there a function to round numbers to the nearest odd
(or even) integer? The ODD function always rounds up,
whereas I want to round my data to the nearest odd
number. i.e. 1.5 rounding to 1 rather than 3

Thanks,
Andrew Moeser
 
H

Harlan Grove

Is there a function to round numbers to the nearest odd
(or even) integer? The ODD function always rounds up,
whereas I want to round my data to the nearest odd
number. i.e. 1.5 rounding to 1 rather than 3

Sorry for preceding blank response.

You mean 1.5 returning 1 rather than 2?

If so, =ROUND((X-1)/2,0)*2+1
 
K

Ken Wright

LOL - I know I'm going to regret this Harlan, but a chance like this I get once in a blue moon
only <vbg>

Believe OP was correct in his statement of it wanting it rounding to 1 instead of 3, not 2, due to
the ODD function.

With the exception of not knowing how he wants to handle a 2, or 4, or 6 etc, the following should
sort him out:-

=ODD(ROUNDDOWN(A1,0))

The 2, 4, 6 etc will round up to the next odd integer.
 
N

Norman Harker

Hi Andrew!

You need to also define what you want to do to the midway point (even
numbers)

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
Holidays and Observances Saturday 2nd August: Andorra (Andorra La
Vella), Bosnia - Herzegovina (Ilindan), Costa Rica (Virgin of the
Angels Day), Macedonia (Ilinden / St. Elijah's Day), St. Kitts & Nevis
(Emancipation Day), Yugoslavia (Ilinden / St. Elijah's Day).
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
K

Ken Wright

My message just got purged - No idea why, but let's try again:-


Hi Harald, No argument there, and Harlan's will be quicker than mine anyway because I use two
functions (Though possibly slightly easier to read perhaps for the OP), but it was Harlan's
correction about the OP meaning 2 instead of 3 when he used the ODD function that I was referring
to. .
You mean 1.5 returning 1 rather than 2?

vs the OPs
i.e. 1.5 rounding to 1 rather than 3

when in fact I believe the OP was correct about it rounding to 3.

Didn't mean to give the impression his solution didn't work, so apologies.
 
H

Harald Staff

it was Harlan's
correction about the OP meaning 2 instead of 3 when he used the ODD function that I was referring
to. .

Oops. Misunderstood totally again.

For L = 1 to 100
MsgBox "Sorry"
Next
 

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